When I try to call https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token} from my backend server to verify a purchase I receive :
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"errors": [
{
"message": "Login Required.",
"domain": "global",
"reason": "required",
"location": "Authorization",
"locationType": "header"
}
],
"status": "UNAUTHENTICATED"
}
}
How can I authenticate from my backend server (so without any user interface)? Is there any way to create an API key somewhere and use it to authenticate?
The error message
Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
States that authorization is required.
If you check the documentation for Method: purchases.subscriptions.get
You will notices that it states that this method requires authorization with the following scope
Assuming this is an account you the developer control and you only want to access this single account you should look into using a service account for authorization. Documentation here Using a service account