donny-auth

A client library for authenticating with the donny-auth system

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
donny-auth
1.6.12 years ago7 years agoMinified + gzip package size for donny-auth in KB

Readme

donny-auth
A client library for authenticating with the donny-auth system

install

yarn add donny-auth

usage

const TokenStore = require('donny-auth')

// the source needs to be an html page
const store = new TokenStore('https://auth-store')

store.getToken({
    aud: 'audience'
}).then(function (token) {
    if (!token) {
        // redirect to `store.loginUrl`
    }
    // do stuff with token
}, function (err) {
    // probably means you're not allowed to use donny-auth on this domain
})

// if you have an API2 token
store.upgradeToken({
    aud: 'audience',
    api2_token: 'your-api2-token'
}).then(function (token) {
    if (!token) {
        // redirect to `store.loginUrl`
    }
    // do stuff with token
}, function (err) {
    // probably means you're not allowed to use donny-auth on this domain
})