Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
A anue-fe-sdk
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Jira
    • Jira
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • share
  • anue-fe-sdk
  • Wiki
  • Auth

Last edited by benhsieh0404 Dec 06, 2018
Page history
This is an old version of this page. You can view the most recent version or browse the history.

Auth

Auth Package

Auth package manages application credentials by using Network and Storage.

Import the package

The Auth package exports a class constructor which manages credential to a single tenant.


import Auth from '@anue-fe-sdk/packages/Auth'

new Auth().config({
  host: 'http://api.beta.cnyes.cool/api/'
})

Class Methods

config(authContext:Auth.AuthContext) => AuthAbstract

  • authContext Configuration object

Config the Auth instance


new Auth()
  .config({ host: 'http://api.beta.cnyes.cool/api/' })
  .consumeProviderToken({
    type: 
  })

consumeProviderToken(args:Auth.ProviderToken) => Promise<Auth.Credentials>

  • args An object containing type of the provider and complete token information

Authenticate by given provider token and type, when args.type is google the field idToken is required.


const googleCredentials = await getGoogleCredentials()

const auth = new Auth()
  .config({ host: 'http://api.beta.cnyes.cool/api/' })

await auth.consumeProviderToken({
    type: 'google',
    idToken: googleCredential.id_token,
    accessToken: googleCredential.access_token,
    channel: 'driver'
})

renew() => Promise<Auth.Credentials>

Invoke this method to update credential context using existing idToken, and accessToken. Returns a promise resolves latest credential context after it's finished.

getCredentials() => Auth.Credentials

Returns credential context stored in storage.

Clone repository
  • Auth
  • Home