简体   繁体   中英

com.google.a.a.a.a.l 400 Bad Request { “error” : “invalid_grant” } while inserting row in bigquery

Hi I am working on an android app in which I have integrated BigQuery . I am getting lots of exceptions when inserting records in BigQuery tables. I am not an expert in this so it would be great if you guys could help me on this.

1. Error log

  com.google.a.a.a.a.l: 400 Bad Request
  {
    "error" : "invalid_grant"
  }
         at com.google.a.a.a.a.h.a(TokenRequest.java:307)
         at com.google.a.a.b.a.a.b.f(GoogleCredential.java:384)
         at com.google.a.a.a.a.c.h(Credential.java:489)
         at com.google.a.a.a.a.c.a(Credential.java:217)
         at com.google.a.a.c.r.p(HttpRequest.java:859)
         at com.google.a.a.b.d.c.c(AbstractGoogleClientRequest.java:469)
         at com.test.utils.c.b(CommonUtility.java:3264)
         at com.test.services.NetworkChangeIntentService.onHandleIntent(NetworkChangeIntentService.java:72)
         at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
         at android.os.Handler.dispatchMessage(Handler.java:102)
         at android.os.Looper.loop(Looper.java:146)
         at android.os.HandlerThread.run(HandlerThread.java:61)

2. Error log

  com.google.a.a.a.a.l: 400 Bad Request
  {
    "error" : "invalid_grant"
  }
         at com.google.a.a.a.a.h.a(TokenRequest.java:307)
         at com.google.a.a.b.a.a.b.f(GoogleCredential.java:384)
         at com.google.a.a.a.a.c.h(Credential.java:489)
         at com.google.a.a.a.a.c.a(Credential.java:217)
         at com.google.a.a.c.r.p(HttpRequest.java:859)
         at com.google.a.a.b.d.c.c(AbstractGoogleClientRequest.java:469)
         at com.test.utils.k.a(CommonUtility.java:3156)
         at com.test.utils.k.doInBackground(CommonUtility.java:3078)
         at android.os.AsyncTask$2.call(AsyncTask.java:288)
         at java.util.concurrent.FutureTask.run(FutureTask.java:237)
         at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
         at java.lang.Thread.run(Thread.java:818)

From the TokenRequest line that your application fails at, coupled with the knowledge that in HTTP, a 400 error code means a malformed request, I would say that your problem is that your application is attempting to send incorrectly formatted data, or is sending more/less data than it is expecting.

Also, the error you are getting back is telling you that you have an 'invalid_grant' so this must mean the application received back a rejection reply from the server, due to not being privileged (logged in) to do whatever it is your application is trying to do, most likely because of the malformed request error.

Reading a bit more on the subject, it appears that others have had similar issues.

invalid_grant trying to get oAuth token from google

Their solution was to change the client_id to the email address.

It appears that this is an issue with Google API 'being a mess.'

From what I've read, it appears that it will allow you to connect properly the first time, then invalidate your token for the session, sending back that error that you are getting now.

So the first step you need to take is replacing the client_id with the email address that is associated with the Client Id.

invalid_grat错误通常意味着您要么未将请求标头上的正确授权令牌发送到经过身份验证的端点,要么您将凭据失败到应该从中获取令牌的端点(在这种情况下我会说第二个选项)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM