Refreshing Access Token (Google Ads API)

Hi there,

Iā€™m trying to use the new Google Ads API.

Itā€™s using OAuth2.0 and requires an Access Token that expires after 60 minutes.

To refresh it, I need to make an API call, providing my OAuth2.0 credentials and a Refresh Token (that I got the last time I called for a new Access Token).

Iā€™ve tried to do this using the ā€œGet New Access Tokenā€ form in Postman, but there doesnā€™t appear to be an option for the refresh token.

Iā€™ve been looking in the documentation & YouTube channel, but itā€™s escaped me!

Would really appreciate being pointed in the right direction.

Thank you.

Hi @james4peace!

Thereā€™s a blog post on Medium about automating this flow via pre-request scripts:

Hope that helps!

Hi John-Paul,

I very much appreciate you finding that articleā€¦ it looks perfect.

Quick questionā€¦ itā€™s using a variable ā€œBasic_Authā€ and the article says:

ā€œā€¦ you can use this variable to pass in a basic authentication header with your Client Id and Client Secretā€

Is there documentation on how to create such a header and give it a variable name?

Thank you

No problem!

In this tutorial, it looks like the Basic_Auth is a Collection variable.

To add a header with a variable value, simply add a header to your request and for the value add {{variableName}}. If you want Basic_Auth to end up in the header, then set the value to {{Basic_Auth}}.

Hi Jean Paul,

Thank you for thatā€¦

The thing that confuses me is that itā€™s saying that the Basic Authentication Header should include my OAuth2.0 Client ID and Client Secret. How do I group these two strings into a single variable (ā€œBasic Oauthā€).

Secondly, the demo is using: ā€˜Authorizationā€™: pm.variables.get(ā€œBasic_Authā€)

Unless Iā€™m mistaken, is this not for getting a Local Variable? If it was a Collection Variable, would it not have to state: pm.collectionVariables.getā€¦ ?

https://learning.postman.com/docs/postman/variables-and-environments/variables/

Hmm, Iā€™m not sure why itā€™s saying that to be honestā€¦let me check with our team and see if I can come up with a different example of doing this.

pm.variables.get() can be a little misleading. It gets a variable value from whatever the narrowest scope is, itā€™s not limited to local only. In other words, if I have variable1 as a global, and an environment variable, it will return the environment variable value.
https://learning.postman.com/docs/postman/variables-and-environments/variables/#variable-scopes

Hi @john-paul and @james4peace,

Did you ever get this sorted? I am running into the same issue where I am trying to get the refresh access token using Google APIs and used the Medium article mentioned as a base. The {{Basic_Auth}} part is also tripping me up.