1.0.0-rc.3 • Published 2 years ago

@lazy/oauth2-implicit-grant-client v1.0.0-rc.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Lazy Oauth2 Implicit Grant Client


Table of Contents

Example

import { getAccessToken, handleImplicitGrantCallback } from '@lazy/oauth2-implicit-grant-client'

handleImplicitGrantCallback()

const token = await getAccessToken('https://api.example.com/authorize', {
  client_id: 'example-client-id',
})

API

getAccessToken

The getAccessToken function handles the Implicit Grant authentication flow. A new window is created where the user is then prompted to authenticate with the Oauth2 provider, once the user had accepted or rejected the request the handleImplicitGrantCallback function then handles the response and returns it back via the promise from getAccessToken - just like magic.

Parameters

  • endpoint - string - The Authorization endpoint of the Oauth2 provider.
  • parameters - object - The Oauth2 parameters such as; client_id, scope, or redirect_uri.

Example

import { getAccessToken } from '@lazy/oauth2-implicit-grant-client'

const token = await getAccessToken('https://api.example.com/authorize', {
  client_id: 'example-client-id',
})

Returns Promise<string>

handleImplicitGrantCallback

The handleImplicitGrantCallback function is responsible for returning the response from the authentication endpoint back to the getAccessToken function. If you call the getAccessToken and handleImplicitGrantCallback functions in the same page make sure you call the handleImplicitGrantCallback function before the getAccessToken.

Example

import { handleImplicitGrantCallback } from '@lazy/oauth2-implicit-grant-client'

handleImplicitGrantCallback()
1.0.0-rc.3

2 years ago

1.0.0-rc.2

3 years ago

1.0.0-rc.1

3 years ago

1.0.0-rc.0

3 years ago