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.