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

Auth · Changes

Page history
Edited online authored Dec 06, 2018 by benhsieh's avatar benhsieh
Hide whitespace changes
Inline Side-by-side
Showing with 73 additions and 0 deletions
+73 -0
  • Auth.md Auth.md +73 -0
  • No files found.
Auth.md 0 → 100644
View page @ 0263275d
# 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.
```ts
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
```ts
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.
```ts
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.
\ No newline at end of file
Clone repository
  • Auth
  • Home