How to get access token

66 views
Skip to first unread message

Георгий Грязнов

unread,
Jun 19, 2018, 4:16:05 PM6/19/18
to AdWords API and Google Ads API Forum

Hi there. Please help me to get the access token.

I want to get a static access token which will not expire in hour (day, month). I will use it in the App which allows me to send only one HTTP request. So, I need static access token to include it the request one time and not to change it. Is it possble? If yes, which doc to learn?

Thanks and sorry for my bad english....

I tried to create access token for desktop app, but the next step was getting it with the request:

curl -s -d code=4/XxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxX -d grant_type=authorization_code -d client_id=YyYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyY.apps.googleusercontent.com -d client_secret=WwWwWwWwWwWwWwWwWwWwWwWw -d redirect_uri=urn:ietf:wg:oauth:2.0:oob https://www.googleapis.com/oauth2/v4/token

responce: 
{
 "error": "invalid_grant",
 "error_description": "Bad Request"
}

Luis Xander Talag (AdWords API Team)

unread,
Jun 20, 2018, 12:06:16 AM6/20/18
to AdWords API and Google Ads API Forum
Hi,

You could use one of our client libraries which will allow you to automatically generate an access token when making a request. All you need to do is to specify your OAuth2 credentials in the property file including your refresh token. 

The invalid_grant error you encountered normally occurs due to expired refreshToken. To resolve this issue, you may try to regenerate the refreshToken and the OAuth2 credentials using an email address which currently has access to your AdWords account and then retry the request again. 

Feel free to write back for any clarifications.

Thanks and regards,
Luis
AdWords API Team
Message has been deleted

Георгий Грязнов

unread,
Jun 20, 2018, 5:53:02 AM6/20/18
to AdWords API and Google Ads API Forum
OK,
So, I use a laptop with installed Win7 and my App is a third-side desktop app. What kind of library should I choose to make it work atlast? 



среда, 20 июня 2018 г., 9:06:16 UTC+5 пользователь Luis Xander Talag (AdWords API Team) написал:

Luis Xander Talag (AdWords API Team)

unread,
Jun 20, 2018, 6:29:05 AM6/20/18
to AdWords API and Google Ads API Forum
Hi,

All those client library are capable of automatically generating of access token. You should choose the client library that you are most comfortable with when developing.

Regards,
Luis
AdWords API Team
Reply all
Reply to author
Forward
Message has been deleted
0 new messages