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
- PasswordGrantAuth :
SessionType
- new PasswordGrantAuth(sdk)
- .getCurrentApiToken() ⇒
Promise
- .isAuthenticated() ⇒
boolean
- .logIn(username, password) ⇒
Promise
- .logOut() ⇒
Promise
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'
});
Gets the current API token (used to communicate with other Contxt APIs)
Kind: instance method of PasswordGrantAuth
Fulfills: string
apiToken
Rejects: Error
Tells caller if the current user is authenticated
Kind: instance method of PasswordGrantAuth
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 |
Logs the user out by removing any stored session info.
Kind: instance method of PasswordGrantAuth
Fulfills: string