May 15, 2022
Posted by: Rahul Upadhyay
This section will provide you steps to request access tokens with the specific scope https://www.googleapis.com/auth/androidpublisher using OAuth 2.0 Assertion Profile
Why do we need this access_token?
What do we read from the JSON file?
$ curl -X POST https://accounts.google.com/o/oauth2/token
-H 'Content-Type: application/x-www-form-urlencoded'
-d 'grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion= eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJwbGF5LWRldmVsb3Blci1hcGlAcGMtYXBpLTU3MDg2MDAxMjU3MTE1Mjk1OTMtOTE4LmlhbS5nc2VydmljZWFjY291bnQuY29tIiwic2NvcGUiOiJodHRwczovL3d3dy5nb29nbGVhcGlzLmNvbS9hdXRoL2FuZHJvaWRwdWJsaXNoZXIiLCJhdWQiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20vby9vYXV0aDIvdG9rZW4iLCJpYXQiOjE2NDkxNDczNzAsImV4cCI6MTY0OTE1MDk5M30'
By default, these parameters must be x-www-form-urlencoded and specified in the request body (as shown in the sample above). Also, to use a JWT Bearer Token as an authorization grant, use the following parameter values and encodings.
The following example JSON object, used as the header of a JWT, declares that the JWT is signed with the RS256 algorithm
Below is an example JSON object that could be encoded to produce the JWT Claims Object for a JWT:
- Encode your payload and headers with the PRIVATE_KEY extracted from the JSON file
We are going to use this encoded value as an assertion token in the next step.
We are going to pass this formData to the next step, i.e., HTTP call.
Success response | 200 (OK)
Using this access token, you can call the subsequent API calls. See this document for usage.