OAuthAuthorization
Class used to authorize a mobile user against Oracle Mobile Hub. Callers should use
MobileBackend's authorization property.
- Source:
Extends
Members
isAuthorized :Boolean
Is SDK authorized.
Returns true if a user has been authorized, false otherwise.
A user can be authorized by calling authenticate() or authenticateAnonymous().
Type:
- Boolean
- Inherited From:
- Source:
Methods
authenticate(username, password) → {Promise.<NetworkResponse>}
Authenticate.
Authenticates a user with the given credentials against the service.
The user remains logged in until logout() is called.
Parameters:
Name | Type | Description |
---|---|---|
username |
String | The username of the credentials. |
password |
String | The password of the credentials. |
- Source:
Returns:
- Type
- Promise.<NetworkResponse>
authenticateAnonymous() → {Promise.<NetworkResponse>}
Authenticate anonymous.
Authenticates an anonymous user against the service. The user remains logged in until logout() is called.
- Source:
Returns:
- Type
- Promise.<NetworkResponse>
getAccessToken() → {String}
Get access token.
Returns the current access token from user credentials.
- Inherited From:
- Source:
Returns:
current access token from user credentials.
- Type
- String
getAuthorizedUserName() → {String}
Get authorized username.
Returns the username of the current authorized user if any, null otherwise.
- Source:
Returns:
- Type
- String
getClientId() → {String}
Get client id.
Returns the client ID for the current backend.
- Source:
Returns:
- Type
- String
getClientSecret() → {String}
Get client secret.
Returns the client secret for the current backend.
- Source:
Returns:
- Type
- String
getOAuthTokenUrl() → {String}
Get OAuth token url.
Constructs a full URL, including the prefix, for the OAuth token endpoint.
- Source:
Returns:
The full URL for the OAuth token endpoint.
- Type
- String
isTokenValid() → {Boolean}
Is authentication token valid.
Checks to see if the OAuth token is null, undefined, NaN,an empty string (""), 0,or false.
It also checks the timestamp
for when the token was first retrieved to see if it was still valid.
- Source:
Returns:
- Type
- Boolean
logout()
Log out.
Logs out the current user and clears credentials and tokens.
- Source:
onAuthentication(callback)
On authentication event.
Subscribe for on authentication event
Parameters:
Name | Type | Description |
---|---|---|
callback |
Authorization~OnAuthenticationCallback | The callback that will be called when authentication happen. |
- Inherited From:
- Source:
refreshToken() → {Promise.<NetworkResponse>}
Refresh token
For OAuth, the SDK can not refresh because it does not persist client credentials.
This function only exists here because it inherits from the Authorization object,
which is also used for other types of authentication in which the token can expire.
- Source:
Returns:
- Type
- Promise.<NetworkResponse>