6.0.2 • Published 4 years ago

@hiro-graph/implicit-oauth v6.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

@hiro-graph/implicit-oauth: Implicit OAuth flow helper

A simple oauth implicit flow, with options for a Popup or a Redirect based

installation

$ npm install @hiro-graph/implicit-oauth

Usage example

import { Popup } from "@hiro-graph/implicit-oauth"

const config = {
    url: "https://your/authorize/url...",
    clientId: "...yourClientId"
};

// Your login button
const loginButton = document.getElementById("loginButton")

const { check, request } = Popup(config);

const authCallback = (err, token) => {
    if (err) {
        //something bad happened :(
        console.warn(err);
    }
    if (token) {
        // User logged in successfully
        // access token at `token.accessToken`
        // metadata at `token.meta`
        document.write("Logged In: " + token.accessToken);
    }
});

//perform passive login check
check(authCallback);

// Trigger implicitOauth when clicked (open popup)
loginButton.addEventListener("click", () => request(authCallback));
6.0.2

4 years ago

7.0.2

5 years ago

7.0.1

5 years ago

7.0.0

5 years ago

6.0.0

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago