Skip to content

Latest commit

 

History

History
81 lines (63 loc) · 3.18 KB

PasswordGrantAuth.md

File metadata and controls

81 lines (63 loc) · 3.18 KB

PasswordGrantAuth : SessionType

A SessionType that allows the user to authenticate with Auth0 and then gain a valid JWT from the Contxt Auth service. This method utitlizes the password grant type authorization with Auth0. This SessionType will expect a username and a password to be passed into the logIn function from the user to authenticate.

Kind: global class

new PasswordGrantAuth(sdk)

Param Type Description
sdk Object An instance of the SDK so the module can communicate with other modules
sdk.audiences Object
sdk.audiences.contxtAuth Object
sdk.audiences.contxtAuth.clientId string The Auth0 client id of the Contxt Auth environment
sdk.audiences.contxtAuth.host string
sdk.config Object
sdk.config.auth Object
sdk.config.auth.clientId string The Auth0 client id of the application

Example

const ContxtSdk = require('@ndustrial/contxt-sdk');

const contxtService = new ContxtSdk({
  config: {
    auth: {
      clientId: '<client id>'
    }
  },
  sessionType: 'passwordGrantAuth'
});

contxtSdk.auth.getCurrentApiToken() ⇒ Promise

Gets the current API token (used to communicate with other Contxt APIs)

Kind: instance method of PasswordGrantAuth
Fulfills: string apiToken
Rejects: Error

contxtSdk.auth.isAuthenticated() ⇒ boolean

Tells caller if the current user is authenticated

Kind: instance method of PasswordGrantAuth

contxtSdk.auth.logIn(username, password) ⇒ Promise

Logs the user in using Auth0 using a username a password

Kind: instance method of PasswordGrantAuth
Fulfills: string
Rejects: Error

Param Type Description
username string The username of the user to authenticate
password string The password of the user to authenticate

contxtSdk.auth.logOut() ⇒ Promise

Logs the user out by removing any stored session info.

Kind: instance method of PasswordGrantAuth
Fulfills: string