1.0.2 • Published 1 year ago

@zaobao/okta-oauth v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

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

methodcomments
authorizeEndpoint进行一些列检查判断是否正常授权
isAuthorized与authorizeEndpoint方法类似,建议使用isAuthorized
configureClient设置初始信息,在调用其他方法之前调用,参数:{clientId, redirectUri, endPoint, tokenHost, logoutHost}
getAccessToken获取access_token
getIdToken获取idtoken
getRefreshToken获取refresh token
logout退出登录
1.0.2

1 year ago

1.0.2-beta.1

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

1.0.0-beta.1

1 year ago

1.0.0-beta.0

1 year ago