Skip to content

sylvanld/octoauth-client-javascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OctoAuth javascript client

Client library for OctoAuth identity server...

Installation

npm install --save octoauth-client

Description

pkce-flow-for-public-client.png Illustration: implementation of pkce flow for public client

Usage

Instanciate OctoAuth client.

import {OctoAuthClient} from 'octoauth-client'

const octo = new OctoAuthClient({
    clientId: 'social-network', 
    redirectURI: 'http://social.example.com', 
    scopes: ['friends:read', 'friends:edit'], 
    serverURL: 'https://accounts.example.com'
})

Redirect user to authorization server's /authorize view

octo.redirectToAuthorization();

Handle authorization response (will redirect to authorization if no response is found)

const authorizationCode = octo.getAuthorizationCode()
octo.getTokenGrantFromCode(authorizationCode)
    .then(()=>console.log("token grant has been loaded"))
    .error(()=>console.log("failed to get tokenGrant"));

Reload authorization from stored refresh_token

octo.reloadAuthorization()
    .then(()=>console.log("authorization reloaded"))
    .error(()=>console.log("no suitable authorization stored"));

Register a function notified on token change

octo.accessToken.addObserver(accessToken=>{
    console.log("new access token value", accessToken);
})

Sources

Roadmap

  • Support both implicit flow, and authorization code with PKCE.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published