Airbnb OAuth Wrapper for Nodejs
$ npm install airbnb-oauth --save
Get client ID and client secret: https://www.airbnb.com/partner
const OAuth = require('airbnb-oauth');
const client = new OAuth('clientId', 'clientSecret');
const url = client.getAuthorizeURL('redirectUrl', 'state', 'scope');
const result = await client.getAccessToken('code');
Example Response
{
"access_token": "40xdf4fvdotrpnwv6tkuroaze",
"expires_at": 1422594787,
"refresh_token": "d1gwltceepbiouw6dznxpf7k2",
"user_id": 1603070
}
const result = await client.checkTokenStatus('accessToken');
Example Response
{
"expires_at": 1422595153,
"token": "e8ef4q56gf840g3vnnobub4a5",
"token_type": "access_token",
"user_id": 1603070,
"valid": true
}
const result = await client.refreshToken('accessToken');
// reset your refresh token
const result = await client.refreshToken('accessToken', 1);
Example Response
{
"access_token": "40xdf4fvdotrpnwv6tkuroaze", // new access token to use in API calls for the next 24 hours
"expires_at": 1422594787, // Unix time
"refresh_token": "d1gwltceepbiouw6dznxpf7k2", // returned if reset_refresh_token was set to 1
"user_id": 1603070
}
const result = await client.revokingToken('accessToken');
// limit: optional, defaults is 25
// offset: optional, defaults is 0
const result = await client.retrieveAllHosts('limit', 'offset');
Example Response
{
"count":2,
"items":[
{
"user_id":22909678
},
{
"user_id":18890019
}
]
}