0.3.0 • Published 9 months ago

@jfront/oauth-context v0.3.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
9 months ago

oauth-context

React Context API OAuth 2.0 authorization management.

Usage

import { OAuthContextProvider, useOAuth } from "@jfront/oauth-context"

function Component() {
  const context = useOAuth()
  return <div>{context.expiresIn}</div>
}

function App() {
  return (
    <OAuthContextProvider
      onAuthorizationRequest={onAuthorizationRequest} //submit redirect after authorization URL is ready
      isOAuthCallback={isOAuthCallback} //pass function which will determine if current route is OAuth callback
      redirect={redirect} //pass function which allows to forward application between routes with URL scheme
      getCurrentUrl={getCurrentUrl} //pass function which gets current route URL scheme
      getQueryParams={getQueryParams} //pass function which gets OAuth params from current URL (code, state, error, errorDescription)
      clientId={"clientId"}
      redirectUri={"http://server/app/cb"}
      oauthContextPath={"http://server/oauth/api"}
      storage={window.sessionStorage} //pass your platform storage, for browser default is HTML5 Session Storage
      onLogout={onLogout} //submit logout URL
    >
      <Component />
    </OAuthContextProvider>
  )
}
0.3.0

9 months ago

0.2.2

1 year ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago