Best answer

Trouble getting Google API refresh token for custom integration.

  • 4 May 2020
  • 2 replies
  • 1172 views

Userlevel 1

I am creating a custom integration using the Google Calendar API. I can get the oauth2 authentication to work initially, but it stops working after about an hour. I am trying to get a refresh token, but my guess is that something in that process is not working. 

 

I have setup these URL parameters:

response_type = code

approval_prompt = force (I’ve tried ‘consent’ but same results)

access_type = offline

 

How can I get my authorization to stick?

 

icon

Best answer by reevesc 5 May 2020, 19:42

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Userlevel 7
Badge +12

@reevesc - You should add set these query params in the authorization URL:

client_id: Your OAuth2 CLIENT_ID

state: “{{bundle.inputData.state}}”

redirect_uri: “{{bundle.inputData.redirect_uri}}”

response_type: “code”

prompt: “consent”

access_type: “offline”

 

This should allow you refresh the token without having to interact with the user.

Userlevel 1

Thank you for the reply. I was able to get this fixed.

 

In the end, I set up my Authorization URL parameters as you mentioned.

 

For my access token request I have:

code: {{bundle.inputData.code}}

client_id: {{process.en.CLIENT_ID}}

client_secret: {{process.env.CLIENT_SECRET}}

grant_type: authorization_code

redirect_uri: {{bundle.inputData.redirect_uri}}

 

And for Refresh Token Request

client_id (same as above)

client_secret (same as above)

grant_type: refresh_token

refresh_token: {{bundle.authData.refresh_token}}

 

It’s now working flawlessly!

This documentation helped:

https://developers.google.com/identity/protocols/oauth2/native-app#offline