bitmart-oauth-sdk
v0.4.0
Published
## Install
Downloads
5
Readme
Bitmart OAuth Nodejs SDK
Install
npm i bitmart-oauth-sdk
User's guidance
Log in at the official bitmart login link to get authorizeCode. Then call the following method to get accessToken and other required content
import { createToken, refreshToken } from 'bitmart-oauth-sdk'
// (Commonjs module) const oauth = require('bitmart-oauth-sdk')
// (Commonjs module) oauth.createSign('123', '123', '123', Date.now())
/**
* Get token
* @param clientId
* @param authorizeCode
* @param clientSecret
* @param options url is a example, you can read our apiDoc
*/
createToken('123', '123', '123', {
url: 'http://api.bitmartdev.com/user-center/oauth/access-token',
application: 'SG',
})
/**
* Every so often, the token will become invalid and need to be re-obtained
* @param clientId
* @param refreshToken
* @param clientSecret
* @param options url is a example, you can read our apiDoc
*/
refreshToken('123', '123', '123', {
url: 'http://api.bitmartdev.com/user-center/oauth/access-token/refresh',
application: 'SG',
})
// createToken,refreshToken (Response example)
{
"code": 0,
"message": "OK",
"data": {
"accessToken":"xxxxxxxxxxxx.xxxxxxxxxx.xxxxxxxx",
"accessSalt":"7YB3FLXO812",
"refreshToken":"3F0XG5Qx2TlKWIA4cd123",
"expireIn": 1444
}
}
Additional methods to generate signatures are available
import { createToken, refreshToken } from 'bitmart-oauth-sdk'
const now = Date.now()
/**
* generate signatures
* @param clientId
* @param authorizeCode
* @param clientSecret
* @param timestamp
*/
const sign = createSign('123', '123', '123', now)