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.
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.
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.
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
- server implementation is wrong or client side implementation wrong or url
- parameters are wrong
- check for
<uses-permission android:name="android.permission.INTERNET" />
in your AndroidManifest.xml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With