@zaobao/okta-oauth
v1.0.2
Published
okta oauth login verify
Downloads
23
Readme
Okta login oauth
Install
npm i @zaobao/okta-oauth
Getting started
use in browser (IIFE)
原生网页中,会在window
中暴露 OktaOAuth
对象,使用OktaOAuth.xxx
即可使用okta相关api
<script src="path to/dist/index.iife.js"></script>
<script>
OktaOAuth.configureClient({
clientId:'',
redirectUri:location.origin + location.pathname,
endPoint:'https://xxxx/oauth2/v1/authorize',
tokenHost:'https://xxxx/oauth2/v1/token',
logoutHost:'https://xxxx/oauth2/v1/logout'
})
OktaOAuth.isAuthorized().then(()=>{
// init
})
</script>
use in any framework (ESM)
import {isAuthorized} from "@zaobao/okta-oauth";
configureClient({
clientId:'',
redirectUri:location.origin + location.pathname,
endPoint:'https://xxxx/oauth2/v1/authorize',
tokenHost:'https://xxxx/oauth2/v1/token',
logoutHost:'https://xxxx/oauth2/v1/logout'
})
isAuthorized().then(()=>{
// init app
})
Api
| method | comments | |-------------------|--------------------------------------------------------------------------------| | authorizeEndpoint | 进行一些列检查判断是否正常授权 | | isAuthorized | 与authorizeEndpoint方法类似,建议使用isAuthorized | | configureClient | 设置初始信息,在调用其他方法之前调用,参数:{clientId, redirectUri, endPoint, tokenHost, logoutHost} | | getAccessToken | 获取access_token | | getIdToken | 获取idtoken | | getRefreshToken | 获取refresh token | | logout | 退出登录 |