Mar 31, 2020 12:06 PM
Hello, I am trying to create an OAuth connection inside of a .NET application and wanted to make sure I have the correct process down. Are these the correct steps?
0. Authorize the Developer Application to reach the other HubSpot Application
However, since the "code" value expires every 10 minuntes, I need to programmatically generate it but am unable to get the redirect url after making an API call. Do you all any same code that's not in Node I can use for reference for completely step 1?
Is this also the correct route or should I be authentication via the API Key?
Mar 31, 2020 1:25 PM
so the way I do it in a PHP app I created:
Mar 31, 2020 1:33 PM - edited Mar 31, 2020 1:33 PM
Thanks for the response.
So I can't do the first part of obtaining the code programatically? I think your solution is pretty good, but I'm nervous if the jobs fails in the middle of night (for whatever reason) then our HubSpot Integration would break completely. Has this happened to you at all?
Do you then* store your new token somewhere? Maybe a secure, encyrpted storage, where your web application retrieves it before making an api call?
Apr 2, 2020 11:40 AM
Thanks for jumping in, @benvanlooy!
@bmicucci, to add additional context, it is not possible to generate the
code programmatically because the OAuth 2.0 Authorization Code grant type, which HubSpot applications use, requires a user to grant access.
Once a user grants access and lands on your
redirect_uri, however, your app can programmatically grab it and pass it to your function which calls this endpoint.
You will usually only have to collect the
code once per connection (which is per account), because once you use the
code to generate your first
refresh_token, you can store the
refresh_tokenand use it to refresh the access token, as @benvanlooy does in "Step 3."
refresh_token values should be stored securely.
Hope that helps clarify!
Isaac TakushiAssociate Certification Manager