@zaobao/okta-oauth
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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 退出登录

Readme

Keywords

Package Sidebar

Install

npm i @zaobao/okta-oauth

Weekly Downloads

7

Version

1.0.2

License

ISC

Unpacked Size

79.9 kB

Total Files

7

Last publish

Collaborators

  • zxiangyun
  • v1zhangming