$this->oath2 = new OAuth2([ 'authorizationUri' => self::AUTHORIZATION_URI, 'tokenCredentialUri' => CredentialsLoader::TOKEN_CREDENTIAL_URI, 'redirectUri' => self::BASE_URL . self::REDIRECT_PATH, 'clientId' => self::CLIENTID, 'clientSecret' => self::CLIENTSECRET, 'scope' => self::API_SCOPE]);$this->oauth2->setRefreshToken($refresh_token); // let's assume $refresh_token was retrieved from database
$this->session =
(new AdWordsSessionBuilder()) ->withDeveloperToken(self::DEVELOPER_TOKEN) ->withOAuth2Credential($this->oauth2)
->build();
// Make some API calls with AdWordsServices and $this->session$oauth2 =(new OAuth2TokenBuilder())
->withClientId('client_id') // replace with real values
->withClientSecret('client_secret') // replace with real values
->withRefreshToken('refresh_token') // replace with real values
->withScopes('scopes_urls') // replace with real values
->build();
$session = (new AdWordsSessionBuilder())
->withOAuth2Credential($oauth2)
->withDeveloperToken('dev_token') // replace with real values
->build();
// make API calls with $session based on https://github.com/googleads/googleads-php-lib#basic-usage $oauth2Token = (new OAuth2TokenBuilder())
->withClientId($clientId)
->withClientSecret($clientSecret)
->withRefreshToken($refreshToken)
->build();
$adWordsSession = (new AdWordsSessionBuilder())
->withOAuth2Credential($oauth2Token)
->withDeveloperToken($developerToken)
->build();google.auth.exceptions.RefreshError: ('invalid_grant: Token has been expired or revoked.', '{\n "error": "invalid_grant",\n "error_description": "Token has been expired or revoked."\n}')Hi Nazar,
I am Nikisha from the Google Ads API team. If you are using our client libraries while making call to the API, it will automatically take care of refreshing the expired access tokens. The access token will be valid for only 3600 seconds after it is generated, so this might be a reason for you to face this error. Also, you are only allowed to generate 50 refresh tokens from an account, generating more than 50 refresh tokens will cause the oldest tokens to be revoked automatically. Could you please verify your refresh token, elaborate how are you creating them and accessing your account to help further? Could you try to generate a new refresh token using the instructions for the specific client library you are using and let me know if there are still issues?
Regards,
Nikisha Patel, Google Ads API Team
google.ads.google_ads.client.GoogleAdsClient.load_from_storage("root_to_yaml_file")google-ads-python/examples/basic_operations/get_campaigns.py
Request made: ClientCustomerId: <CLIENT_CUSTOMER_ID>, Host: googleads.googleapis.com:443, Method: /google.ads.googleads.v2.services.GoogleAdsService/Search, RequestId: None, IsFault: True, FaultMessage: Request had insufficient authentication scopes.
google.auth.exceptions.RefreshError: ('invalid_grant: Token has been expired or revoked.', '{\n "error": "invalid_grant",\n "error_description": "Token has been expired or revoked."\n}')
revoked?insufficient authentication scopes during getting campaings?
Hi Nazar,
Please find my response to your queries below:
It looks like that we were running few applications in parallel and all of them where automatically updating token via your lib. Is it possible that due to that refresh token was revoked? It might be possible that the refresh token was revoked because of this operation as you are only allowed to generate 50 refresh tokens from an account and generating more than 50 refresh tokens can cause the oldest token to be revoked automatically.
Let us know if you need any further clarifications.
Regards,
Nikisha Patel, Google Ads API Team
Hi Nazar,
We haven't received the response yet. Could you please retry sharing the requested information using Reply privately to author option for me to assist you better?
Regards,
Nikisha Patel, Google Ads API Team
Few minutes ago I resend it and received information that my message was sent (see screnshoot below ). Let me know iif you received my message privately :
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/2f3e8c17-f678-43c1-976e-0b70c27c2151%40googlegroups.com.
Hi Deepa,
Thanks for commenting on this forum thread.
Could you provide us with the complete request and response logs with the request-id, so our team can better check?
If you are using a client library, you may first enable logging by navigating to the Client libraries > Your client library (ex. Java) > Logging documentation, which you can access from this link. You may then send the requested information via the Reply privately to author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead.
Regards,
|
||||||