PersonalAuthAPI - Scoped
The PersonalAuthAPI provides methods that enable you to manage access/refresh tokens for personal authentication credentials.
To access this API the Personal Authentication (com.snc.sn_ihub_personal_auth) plugin must be activated. This API runs in the sn_cc namespace.
Before accessing this API, Personal Authentication must be configured on your instance. For additional information, see Create a Connection & Credential alias.
PersonalAuthAPI - PersonalAuthAPI()
Instantiates a new PersonalAuthAPI object.
| Name | Type | Description |
|---|---|---|
| None |
The following code example shows how to instantiate a PersonalAuthAPI object.
var personalAuthAPI = new sn_cc.PersonalAuthAPI();
PersonalAuthAPI - getInitiatorURL(String aliasId)
Returns the OAuth initiator URL for the personal authentication credential associated with a specified alias.
| Name | Type | Description |
|---|---|---|
| aliasId | String | Sys_id of the connection or credential alias whose OAuth initiator URL you want to retrieve. Table: Connection & Credential Aliases [sys_alias] |
| Type | Description |
|---|---|
| String | OAuth initiator URL for the personal authentication credential associated with the specified alias. If the personal authentication credential doesn't exist for the specified alias, the method returns an empty string. |
The following code example shows how to call this method.
var aliasId = "e41b9dd1532102104c4bddeeff7b1250";
var personalAuthAPI = new sn_cc.PersonalAuthAPI();
var result = personalAuthAPI.getInitiatorURL(aliasId);
gs.info(result);
Output:
/oauth_initiator.do?oauth_requestor_context=oauth_2_0_credentials&oauth_requestor=d84b5115532102104c4bddeeff7b12f2&oauth_provider_profile=d84b5115532102104c4bddeeff7b12ec&response_type=code&personal=true
PersonalAuthAPI - isTokenValid(String aliasId)
Checks whether a valid access/refresh token exists for the personal authorization credential associated with a specified alias.
| Name | Type | Description |
|---|---|---|
| aliasId | String | Sys_id of the connection or credential alias to check for the associated personal authorization credential. Table: Connection & Credential Aliases [sys_alias] |
| Type | Description |
|---|---|
| Boolean | Flag that indicates whether there's an associated personal authorization credential for the specified alias ID. Possible values:
|
The following code example shows how to call this method.
var aliasId = "e41b9dd1532102104c4bddeeff7b1250";
var personalAuthAPI = new sn_cc.PersonalAuthAPI();
var result = personalAuthAPI.isTokenValid(aliasId);
gs.info(result);
Output:
true
PersonalAuthAPI - revokeToken(String aliasId)
Revokes an existing access/refresh token for the personal authentication credential associated with a specified alias.
| Name | Type | Description |
|---|---|---|
| aliasId | String | Sys_id of the connection or credential alias whose access/refresh token for the personal authorization credential you want to revoke. Table: Connection & Credential Aliases [sys_alias] |
| Type | Description |
|---|---|
| Object | Object that contains methods that you can call to obtain additional information about the status of the credential and method call. These methods are available until the next time this method is called.
|
The following code example shows how to call this method.
var aliasId = "e41b9dd1532102104c4bddeeff7b1250";
var personalAuthAPI = new sn_cc.PersonalAuthAPI();
var personalAuthResponse = personalAuthAPI.revokeToken(aliasId);
gs.info(personalAuthResponse.getResponseStatus());
gs.info(personalAuthResponse.getExpiryInSeconds());
gs.info(personalAuthResponse.isAuthenticated());
gs.info(personalAuthResponse.getCredentialId());
Output:
SUCCESS
0
false
d84b5115532102104c4bddeeff7b12f2