Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Play API returning error 401

I'm using gradle-play-publisher library to upload my app to Google Play, but I get error 401 Unauthorized when executing the publishing task. My dev account at Google Play and service account at Dev Console are set up. Play API is enabled.

As I see from build logs, the first request sent is:

POST https://accounts.google.com/o/oauth2/token

I get 200 OK and the following json:

{
  "access_token" : "< some value here>",
  "token_type" : "Bearer",
  "expires_in" : 3600
}

Then the next request is sent:

POST https://www.googleapis.com/androidpublisher/v2/applications/< my app's package name here>/edits

First of all, I noticed this header among others:

Authorization: <Not Logged>

And second, I get this error as a response

401 Unauthorized
WWW-Authenticate: Bearer realm="https://accounts.google.com/", error=invalid_token

Has anyone faced the same issue? Everything seems to be set up correctly, so I have no idea what went wrong. Thank you.

like image 465
Alex Timonin Avatar asked Jul 03 '15 15:07

Alex Timonin


People also ask

What is 401 error code in API?

The HyperText Transfer Protocol (HTTP) 401 Unauthorized response status code indicates that the client request has not been completed because it lacks valid authentication credentials for the requested resource.

How do you remove 401 unauthorized access is denied due to invalid credentials?

In the Authentication Methods dialog, enable either the Integrated Windows authentication box or Basic authentication (password is sent in clear text), and clear all other authentication options for Authentication access.


1 Answers

Your error means that

server responded with 401 (Unauthorized) status code but failed to provide a single auth challenge (WWW-Authenticate header) thus making it impossible for HttpClient to automatically recover from the authentication failure.

Check your HTTP POST request in you application which might expect some short of credentials in the HTML form

I hope that you are already testing your rest API(url) by using POSTMAN google chrome extension.

Now,if your rest api works fine then consider about using that in your code, step by step try to figure out the following

  1. server implementation is wrong or client side implementation wrong or url
  2. parameters are wrong
  3. check for <uses-permission android:name="android.permission.INTERNET" /> in your AndroidManifest.xml
like image 195
SID --- Choke_de_Code Avatar answered Oct 21 '22 19:10

SID --- Choke_de_Code