Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bang9/android-get-access-token-example

example backend that getting android publish token for receipt validation
https://github.com/bang9/android-get-access-token-example

access-token android android-access-token android-validation android-validations iap in-app-billing in-app-purchase inappbilling receipt validation

Last synced: 4 days ago
JSON representation

example backend that getting android publish token for receipt validation

Awesome Lists containing this project

README

        

#### This repository is an example repository for getting access token needed to validate Android receipts.

- follow step 1 below
- replace `service-account.json` file to your account
- `yarn start`

- - - -

### 1. Follow this steps
![image](screenshots/1.png)
![image](screenshots/2.png)
![image](screenshots/3.png)
![image](screenshots/4.png)
![image](screenshots/5.png)
![image](screenshots/6.png)
![image](screenshots/7.png)
![image](screenshots/8.png)
![image](screenshots/9.png)
![image](screenshots/10.png)
![image](screenshots/11.png)

### 2. Create your server
Configure your server safely, this is just for reference! not safety!

```js
const {google} = require('googleapis');
const account = require('./service-account.json');
const express = require('express');

const app = express();

const JWTClient = new google.auth.JWT(
account.client_email,
null,
account.private_key,
["https://www.googleapis.com/auth/androidpublisher"]
);

app.get('/accessToken', (req, res) => {
JWTClient.getAccessToken((err,token)=>{
if(err){
return res.status(404).send("get access token failed");
}

return res.status(200).send(token);
})
});

```

### 3. Done!