TokenResponseException with StatusCode=Internal

729 views
Skip to first unread message

msgu...@gmail.com

unread,
Feb 12, 2023, 1:34:17 PM2/12/23
to Google Ads API and AdWords API Forum
Hi team,

We are hitting a token access issue suddenly.
calling google ads hit this exception since UTC 2022-02-10.
Does anyone know how to resolve it?
[GetCustomers] ExternalServiceHelper.CallWithRetryAsync retry:0, <GetCustomerResult>b__0, Errors:["{\"Code\":\"UnknownError\",\"Property\":\"GetCustomers\",\"Message\":\"Grpc.Core.RpcException: Status(StatusCode=\\\"Internal\\\", Detail=\\\"Error starting gRPC call. TokenResponseException: Error:\\\"invalid_grant\\\", Description:\\\"Bad Request\\\", Uri:\\\"\\\"\\\", DebugException=\\\"Google.Apis.Auth.OAuth2.Responses.TokenResponseException: Error:\\\"invalid_grant\\\", Description:\\\"Bad Request\\\", Uri:\\\"\\\"\\n
   at Google.Apis.Auth.OAuth2.Responses.TokenResponse.FromHttpResponseAsync(HttpResponseMessage response, IClock clock, ILogger logger)\\n
   at Google.Apis.Auth.OAuth2.Requests.TokenRequestExtenstions.ExecuteAsync(TokenRequest request, HttpClient httpClient, String tokenServerUrl, CancellationToken taskCancellationToken, IClock clock, ILogger logger)\\n
   at Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.FetchTokenAsync(String userId, TokenRequest request, CancellationToken taskCancellationToken)\\n
   at Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.FetchTokenAsync(String userId, TokenRequest request, CancellationToken taskCancellationToken)\\n
   at Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.RefreshTokenAsync(String userId, String refreshToken, CancellationToken taskCancellationToken)\\n
   at Google.Apis.Auth.OAuth2.UserCredential.RefreshTokenAsync(CancellationToken taskCancellationToken)\\n
   at Google.Apis.Auth.OAuth2.TokenRefreshManager.RefreshTokenAsync()\\n
   at Google.Apis.Auth.OAuth2.TokenRefreshManager.GetAccessTokenForRequestAsync(CancellationToken cancellationToken)\\n
   at Google.Apis.Auth.OAuth2.TokenRefreshManager.<GetAccessTokenForRequestAsync>g__LogException|10_0(Task task)\\n
   at Google.Apis.Auth.OAuth2.UserCredential.GetAccessTokenWithHeadersForRequestAsync(String authUri, CancellationToken cancellationToken)\\n
   at Grpc.Auth.GoogleAuthInterceptors.<>c__DisplayClass3_0.<<FromCredential>b__0>d.MoveNext()\\n
--- End of stack trace from previous location ---\\n
   at Grpc.Net.Client.Internal.GrpcProtocolHelpers.ReadCredentialMetadata(DefaultCallCredentialsConfigurator configurator, GrpcChannel channel, HttpRequestMessage message, IMethod method, CallCredentials credentials)\\n
   at Grpc.Net.Client.Internal.GrpcCall`2.ReadCredentials(HttpRequestMessage request)\\n
   at Grpc.Net.Client.Internal.GrpcCall`2.RunCall(HttpRequestMessage request, Nullable`1 timeout)\\\")\\n
   at Google.Ads.Gax.Interceptors.UnaryRpcInterceptor.Intercept[T,TResponse](Task`1 task, Action`1 callback)\\n
   at Grpc.Net.Client.Internal.GrpcCall`2.GetResponseHeadersCoreAsync()\\n
   at Google.Ads.Gax.Interceptors.UnaryRpcInterceptor.Intercept[T,TResponse](Task`1 task, Action`1 callback)\\n
   at Google.Api.Gax.Grpc.ApiCall.GrpcCallAdapter`2.<>c__DisplayClass4_0.<<CallAsync>g__WaitAndCallHandlers|0>d.MoveNext()\\n
--- End of stack trace from previous location ---\\n
   at Google.Api.Gax.Grpc.ApiCallRetryExtensions.<>c__DisplayClass0_0`2.<<WithRetry>b__0>d.MoveNext()\\n
--- End of stack trace from previous location ---\\n
   at Google.Api.Gax.Grpc.ResponseAsyncEnumerable`3.ResponseAsyncEnumerator.MoveNextAsync()\\n
   at Microsoft.Ads.Mca.Implementation.AdsSync.Helper.GoogleSyncHelper.<>c__DisplayClass6_0.<<GetCustomerResult>b__0>d.MoveNext()\\n
--- End of stack trace from previous location ---\\n
   at Microsoft.Ads.Mca.Implementation.AdsSync.Helper.GoogleSyncHelper.<>c__DisplayClass6_0.<<GetCustomerResult>b__0>d.MoveNext()\\n
--- End of stack trace from previous location ---\\n
   at Microsoft.Ads.Mca.Common.Client.Common.ExternalServiceHelper.CallWithRetryAsync[T,V](Func`1 func, IExternalServiceExceptionHandler exceptionHandler, ILogShared logger, String property, ValueTuple`2 retryPolicy, V argumentsTuple)\"}"], Raw Exception Grpc.Core.RpcException : Grpc.Core.RpcException: Status(StatusCode="Internal", Detail="Error starting gRPC call. TokenResponseException: Error:"invalid_grant", Description:"Bad Request", Uri:""", DebugException="Google.Apis.Auth.OAuth2.Responses.TokenResponseException: Error:"invalid_grant", Description:"Bad Request", Uri:""
   at Google.Apis.Auth.OAuth2.Responses.TokenResponse.FromHttpResponseAsync(HttpResponseMessage response, IClock clock, ILogger logger)
   at Google.Apis.Auth.OAuth2.Requests.TokenRequestExtenstions.ExecuteAsync(TokenRequest request, HttpClient httpClient, String tokenServerUrl, CancellationToken taskCancellationToken, IClock clock, ILogger logger)
   at Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.FetchTokenAsync(String userId, TokenRequest request, CancellationToken taskCancellationToken)
   at Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.FetchTokenAsync(String userId, TokenRequest request, CancellationToken taskCancellationToken)
   at Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.RefreshTokenAsync(String userId, String refreshToken, CancellationToken taskCancellationToken)
   at Google.Apis.Auth.OAuth2.UserCredential.RefreshTokenAsync(CancellationToken taskCancellationToken)
   at Google.Apis.Auth.OAuth2.TokenRefreshManager.RefreshTokenAsync()
   at Google.Apis.Auth.OAuth2.TokenRefreshManager.GetAccessTokenForRequestAsync(CancellationToken cancellationToken)
   at Google.Apis.Auth.OAuth2.TokenRefreshManager.<GetAccessTokenForRequestAsync>g__LogException|10_0(Task task)
   at Google.Apis.Auth.OAuth2.UserCredential.GetAccessTokenWithHeadersForRequestAsync(String authUri, CancellationToken cancellationToken)
   at Grpc.Auth.GoogleAuthInterceptors.<>c__DisplayClass3_0.<<FromCredential>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Grpc.Net.Client.Internal.GrpcProtocolHelpers.ReadCredentialMetadata(DefaultCallCredentialsConfigurator configurator, GrpcChannel channel, HttpRequestMessage message, IMethod method, CallCredentials credentials)
   at Grpc.Net.Client.Internal.GrpcCall`2.ReadCredentials(HttpRequestMessage request)
   at Grpc.Net.Client.Internal.GrpcCall`2.RunCall(HttpRequestMessage request, Nullable`1 timeout)")
   at Google.Ads.Gax.Interceptors.UnaryRpcInterceptor.Intercept[T,TResponse](Task`1 task, Action`1 callback)
   at Grpc.Net.Client.Internal.GrpcCall`2.GetResponseHeadersCoreAsync()
   at Google.Ads.Gax.Interceptors.UnaryRpcInterceptor.Intercept[T,TResponse](Task`1 task, Action`1 callback)
   at Google.Api.Gax.Grpc.ApiCall.GrpcCallAdapter`2.<>c__DisplayClass4_0.<<CallAsync>g__WaitAndCallHandlers|0>d.MoveNext()
--- End of stack trace from previous location ---
   at Google.Api.Gax.Grpc.ApiCallRetryExtensions.<>c__DisplayClass0_0`2.<<WithRetry>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Google.Api.Gax.Grpc.ResponseAsyncEnumerable`3.ResponseAsyncEnumerator.MoveNextAsync()
   at Microsoft.Ads.Mca.Implementation.AdsSync.Helper.GoogleSyncHelper.<>c__DisplayClass6_0.<<GetCustomerResult>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.Ads.Mca.Implementation.AdsSync.Helper.GoogleSyncHelper.<>c__DisplayClass6_0.<<GetCustomerResult>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.Ads.Mca.Common.Client.Common.ExternalServiceHelper.CallWithRetryAsync[T,V](Func`1 func, IExternalServiceExceptionHandler exceptionHandler, ILogShared logger, String property, ValueTuple`2 retryPolicy, V argumentsTuple)

Thanks,
Guofu

Google Ads API Forum Advisor

unread,
Feb 13, 2023, 5:54:06 AM2/13/23
to msgu...@gmail.com, adwor...@googlegroups.com

Hi,


Thanks for reaching out to the Google Ads API team. I hope you are doing well today.


Upon checking your concern, I can see that you are encountering the invalid_grant error. Please note that the invalid_grant usually indicates an issue with the refresh token. That said, you’ll need to regenerate credentials and refresh tokens. You may refer here to this guide for the steps on how you can regenerate credentials and refresh tokens.

 

On the other hand, you may also check this sample code for generating user credentials.


If the issue still persists, you may provide the complete API request and response logs with request-id and login-customer-id that are generated on your end. If you haven't yet, logging can be enabled by navigating to the Client libraries > Your client library (ex. Java) > Logging documentation, which you can access from this link.


You can provide it via Reply privately to the author option. If this option is not available, then send it instead on this email address googleadsa...@google.com.


Regards,

Google Logo
Darwin
Google Ads API Team
 



ref:_00D1U1174p._5004Q2izKZq:ref

msgu...@gmail.com

unread,
Feb 13, 2023, 6:15:19 PM2/13/23
to Google Ads API and AdWords API Forum
Hi team,

we need a root cause analysis for this issue.
I login the Google cloud platform console via 2-FA on 2022-02-12 19:21 UTC, and the same token started to work again.
Please help us figure out the root cause.

Thanks,
Guofu

Google Ads API Forum Advisor

unread,
Feb 14, 2023, 8:33:31 AM2/14/23
to msgu...@gmail.com, adwor...@googlegroups.com
Hi Guofu,

Thank you for getting back to us. I hope that you are doing well today.

Moving forward to your concern, based on this document:
  • The user has revoked your app's access.
  • The refresh token has not been used for six months.
  • The user changed passwords and the refresh token contains Gmail scopes.
  • The user account has exceeded a maximum number of granted (live) refresh tokens.
  • The user belongs to a Google Cloud Platform organization that has session control policies in effect.
 
If you are asking us to do a deep investigation for your refresh token, I am afraid that we cannot do that as this is already out of our scope for the Google Ads API support team. With this, what we can do is to advise you to reach out to the GCP support team via this link.

Kind regards,
Google Logo
Sherwin Vincent
Google Ads API Team
 


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