4

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)
10 Replies
  • 426
  • 9
  • 25
N Sharma
  • 33,489
  • 95
  • 256
  • 444

2 Answers2

2

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.

Community
  • 1
  • 1
  • Somewhere in your application, your code is attempting to contact a server. That message that your application is trying to send is incorrect, and the server rejects it. The actual malformed request error is the Error Code: "400 Bad Request" –  Aug 04 '15 at 07:29
0

invalid_grat errors usually mean that you are either not sending the correct authorization token on the header of your request to an authenticated endpoint, or you are failing the credentials to the endpoint where you are supposed to get the token from (in this case I would say the second option).

Miguel Mesquita Alfaiate
  • 2,851
  • 5
  • 30
  • 56