@sephora-okta/okta-nodejs-sdk
v1.0.10
Published
okta-nodejs-sdk
Downloads
26
Readme
安装
npm install @sephora-okta/okta-nodejs-sdk
使用
const OKTAsdk = require("@sephora-okta/okta-nodejs-sdk")
const okta = new OKTAsdk({
client_id: "",
client_secret: "",
redirect_uri: "",
scope: "",
response_mode: "",
state: "",
})
// 生成认证地址
let url = okta.getAuthorizationUrl()
- async 调用
根据code获取accesstoken
const token = await okta.getAccessTokenByCode("code")
根据refresh_token获取access_token
const token = await okta.getAccessTokenByRefreshToken("refresh_token")
根据password获取access_token
const token = await okta.getAccessTokenByPassword("username", "password")
根据access_token获取用户信息
const user = await okta.getUserInfoByAccessToken("token")
示例
const oktaFun = async () => {
const tokenObj = await okta.getAccessTokenByCode("code")
const user = await okta.getUserInfoByAccessToken(data.access_token)
}
oktaFun()