android-play-publisher-api icon indicating copy to clipboard operation
android-play-publisher-api copied to clipboard

Java - GoogleJsonResponseException: 401 Unauthorized

Open pstha2017 opened this issue 8 years ago • 7 comments

Hi, I am getting 401 Unauthorized exception while trying to run the java sample code with Service account.

Below is the error stack:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146) at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113) at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321) at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1065) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469) at com.google.play.developerapi.samples.ListApks.main(ListApks.java:55)

The service account was created and has been marked as the owner of the application. Appreciate any kind of help here.

pstha2017 avatar Feb 15 '17 18:02 pstha2017

In google play console, open set Users & permissions menu, set Users with expired access with correct date.

mikeyang01 avatar May 22 '17 12:05 mikeyang01

Hi, I am administrator with no expire date but i get always GoogleJsonResponseException: 401 Unauthorized. How can resolve it ? Thank you

fattanasio avatar Nov 09 '18 10:11 fattanasio

Hello, Somebody succed to manage this ?

Thank you

QuentinSc avatar Apr 25 '19 11:04 QuentinSc

Hello,

I am facing same error (from local machine) as well as from Kubernetes Cluster. Any wayout ?

Thanks.

ghost avatar May 08 '19 20:05 ghost

I have fixed my issue, in the following way:

  1. Service Account json (key.json) file added as kubectl secret.
  2. During my pod spins up, I have put the content of the secret as key.json to a path, mounted in the same pod attached to it.
  3. Then read the key.json from code, it works fine for me.

ghost avatar May 12 '19 06:05 ghost

Please help I'm having the same issue. @arindam-b I don't understand your solution. I'm not working on kubernetes but the prob is same.

spurgy avatar Jun 29 '19 08:06 spurgy

@spurgy - you need to ensure when you access the specific resource, you pass proper credentials interns of service account.json file etc which you can generate from cloud console. Before making request call, it needs to be loaded and allows authorization.

ghost avatar Jun 30 '19 16:06 ghost