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… ?

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.

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.