APIs & Integrations

AbdulQayyum
Participant

How to use/store Oauth Access & Refresh tokens!

SOLVE

I am a newbie and trying to use the oauth of hubspot but don't know how to use it and how it works.

By following the hubspot oauth documentation i have built an app which returns the authorization code, access token, refresh token and expiry. 

What happened after the access token expired as session expired? do the user sent to hubspot server again for oauth?

how can we manage the access token as user will not send to hubspot server for login?

actaully i want to know the full flow of it, is there any app i can test? or if anybody had done this?  

0 Upvotes
1 Accepted solution
Mike_Eastwood
Solution
Key Advisor | Gold Partner
Key Advisor | Gold Partner

How to use/store Oauth Access & Refresh tokens!

SOLVE

Hi @AbdulQayyum 

 

I feel your pain – it took me ages to work it out.

 

I store the tokens in a database then use this API call to refresh the tokens (then store them). I went an extra step and check the timestamp of the saved tokens because the tokens expire.

 

Have you used an SDK in the language of your choice? There's a few SDKs (php node, python, etc.) here.

 

And, I found the Sample Apps really helpful. You'll find the HubSpot-php sample OAuth 2.0 app particularly interesting.

 

Once you get your head around the OAuth the fun begins - I promise.

 

Mike

View solution in original post

2 Replies 2
AbdulQayyum
Participant

How to use/store Oauth Access & Refresh tokens!

SOLVE

Hi @Mike_Eastwood , thnak you. i have build an application for oauth and its working, now trying to integrate it into the main application.

there is confusion in my mind as access token expires in 30 Mins, will it use the refresh token while browing the web app and autometically get the new access token? this is what i understood so far.

0 Upvotes
Mike_Eastwood
Solution
Key Advisor | Gold Partner
Key Advisor | Gold Partner

How to use/store Oauth Access & Refresh tokens!

SOLVE

Hi @AbdulQayyum 

 

I feel your pain – it took me ages to work it out.

 

I store the tokens in a database then use this API call to refresh the tokens (then store them). I went an extra step and check the timestamp of the saved tokens because the tokens expire.

 

Have you used an SDK in the language of your choice? There's a few SDKs (php node, python, etc.) here.

 

And, I found the Sample Apps really helpful. You'll find the HubSpot-php sample OAuth 2.0 app particularly interesting.

 

Once you get your head around the OAuth the fun begins - I promise.

 

Mike