On the cancellation of authorization

178 views
Skip to first unread message

keji dianfei

unread,
Jan 12, 2023, 2:17:52 AM1/12/23
to Google Ads API and AdWords API Forum
When users cancel authorization in Google Security,When the api calls the interface, it will always execute com.google.auth.oauth2.UserCredentials.doRefreshAccessToken circularly, which causes me to not catch this error to modify the authorization status saved in the local database. How to deal with this problem.
The following is the stack of loop execution:
Request
-------
MethodName: google.ads.googleads.v10.services.CustomerService/ListAccessibleCustomers
Endpoint: googleads.googleapis.com:443
Headers: {developer-token=REDACTED, login-customer-id=1, x-goog-api-client=gl-java/1.8.0_341 gccl/17.0.1 gapic/17.0.1 gax/2.6.1 grpc/1.41.0}
Body:

Response
--------
Headers: null
Body: null
Failure message: null
Status: Status{code=UNAVAILABLE, description=Credentials failed to obtain metadata, cause=com.google.api.client.http.HttpResponseException: 400 Bad Request
POST https://oauth2.googleapis.com/token
{
  "error": "invalid_grant",
  "error_description": "Token has been expired or revoked."
}
    at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1116)
    at com.google.auth.oauth2.UserCredentials.doRefreshAccessToken(UserCredentials.java:273)
    at com.google.auth.oauth2.UserCredentials.refreshAccessToken(UserCredentials.java:190)
    at com.google.auth.oauth2.OAuth2Credentials$1.call(OAuth2Credentials.java:257)
    at com.google.auth.oauth2.OAuth2Credentials$1.call(OAuth2Credentials.java:254)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:750)
}.

Google Ads API Forum Advisor

unread,
Jan 12, 2023, 8:49:38 AM1/12/23
to dianf...@gmail.com, adwor...@googlegroups.com

Hi,

Thanks for reaching out to the Google Ads API Forum.

I can see that you are using the Java client library, and with that Java code you are trying to catch the errors encountered due to canceled authorization in Google Security.  Then this is more client library related rather than Google Ads API specific. Note that the client library owners are experts on providing further comments on how com.google.auth.oauth2.UserCredentials.doRefreshAccessToken works, so I recommend you to reach out to Java client library owners here.

Feel free to open a new forum thread for new concerns related to the Google Ads API, and we will assist you further.

Regards,

Google Logo
Yasar
Google Ads API Team
 


ref:_00D1U1174p._5004Q2hxYjJ:ref
Reply all
Reply to author
Forward
0 new messages