oauth-sdk-bm
v0.0.41
Published
## 安装
Downloads
11
Readme
Bitmart OAuth Nodejs SDK
安装
npm i @bitmart/oauth-sdk
使用指南
在官方给出的 bitmart 登录链接登录,获取 authorizeCode。然后调用以下方法获取 accessToken 和其他需要的内容
import { createToken, refreshToken } from '@bitmart/oauth-sdk'
/**
* 获取token
* @param clientId
* @param authorizeCode
* @param clientSecret
* @param options
*/
createToken('123', '123', '123', {
url: 'http://api.bitmartdev.com/user-center/oauth/access-token',
application: 'SG',
})
/**
* 每隔一段时间,token会失效,需要重新获取
* @param clientId
* @param refreshToken
* @param clientSecret
* @param options
*/
refreshToken('123', '123', '123', {
url: 'http://api.bitmartdev.com/user-center/oauth/access-token/refresh',
application: 'SG',
})
// createToken,refreshToken 返回结构如下
{
"code": 0,
"message": "OK",
"data": {
"accessToken":"xxxxxxxxxxxx.xxxxxxxxxx.xxxxxxxx",
"accessSalt":"7YB3FLXO812",
"refreshToken":"3F0XG5Qx2TlKWIA4cd123",
"expireIn": 1444
}
}
额外提供生成签名的方法可供使用
import { createToken, refreshToken } from '@bitmart/oauth-sdk'
const now = Date.now()
/**
* 生成签名
* @param clientId
* @param authorizeCode
* @param clientSecret
* @param timestamp
*/
const sign = createSign('123', '123', '123', now)