---
sourceDocument: Brazil API Reference
sourceDocumentLink: https://www.servicenow.com/docs/r/api-reference

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# PersonalAuthAPI - Scoped

# PersonalAuthAPI - Scoped {#ariaid-title1}

Release version: Brazil  
Updated September 10, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 4 minutes to read  
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](https://www.servicenow.com/docs/access?context=connection-alias&version=brazil&pubname=brazil-platform-security&ft:locale=en-US).

## PersonalAuthAPI - PersonalAuthAPI() {#ariaid-title2}

Instantiates a new PersonalAuthAPI object.
{#PerAuth-PersonalAuthAPI__table_t5w_235_lbc__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 1. Parameters]

{#PerAuth-PersonalAuthAPI__table_t5w_235_lbc}  
The following code example shows how to instantiate a PersonalAuthAPI object.

    var personalAuthAPI = new sn_cc.PersonalAuthAPI();

## PersonalAuthAPI - getInitiatorURL(String aliasId) {#ariaid-title3}

Returns the OAuth initiator URL for the personal authentication credential associated with a specified alias.
{#PerAuth-getInitiatorURL_S__table_fhk_4bl_3bc__entry__3}

| 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\] |
[Table 2. Parameters]

{#PerAuth-getInitiatorURL_S__table_fhk_4bl_3bc} {#PerAuth-getInitiatorURL_S__table_ghk_4bl_3bc__entry__2}

| 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. |
[Table 3. Returns]

{#PerAuth-getInitiatorURL_S__table_ghk_4bl_3bc}  
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 - getOAuthTokenExpiryInfo(String aliasId) {#ariaid-title4}

Retrieves OAuth token expiration information for a specified connection and credential alias.
{#PerAuth-getOAuthTokenExpiryInfo_S__table_gte_prm_1__entry__3}

| Name | Type | Description |
|-|-|-|
| aliasId | String | Sys_id of the connection and credential alias to retrieve OAuth token expiry information for. Table: Connection \& Credential Aliases \[sys_alias\] |
[Table 4. Parameters]

{#PerAuth-getOAuthTokenExpiryInfo_S__table_gte_prm_1} {#PerAuth-getOAuthTokenExpiryInfo_S__table_gte_ret_1__entry__2}

| Type | Description |
|-|-|
| Object | An OAuthTokenExpiryInfo object with methods to obtain expiry information for the access token and refresh token. * getAccessTokenExpiryInSeconds(): Returns the number of seconds until the access token expires. Returns 0 if the token is expired. * getRefreshTokenExpiryInSeconds(): Returns the number of seconds until the refresh token expires. Returns 0 if the token is expired. An object with both the access token and the refresh token marked as expired is returned in the following cases: * aliasId isn't provided or doesn't exist in the sys_alias table. * No OAuth credential is found for the alias. * The expiry information can't be retrieved. {#PerAuth-getOAuthTokenExpiryInfo_S__ul_idh_zvt_clc} |
[Table 5. Returns]

{#PerAuth-getOAuthTokenExpiryInfo_S__table_gte_ret_1}  
The following code example shows how to call this method.

    var aliasId = "279d56efff4321108914224b793bf1d0";
    var personalAuthAPI = new sn_cc.PersonalAuthAPI();
    var expiryInfo = personalAuthAPI.getOAuthTokenExpiryInfo(aliasId);
    gs.info("Access token expiry: " + expiryInfo.getAccessTokenExpiryInSeconds());
    gs.info("Refresh token expiry: " + expiryInfo.getRefreshTokenExpiryInSeconds());

Output:

    Access token expiry: 3540
    Refresh token expiry: 86340

## PersonalAuthAPI - isPersonalAuthEnabled(String aliasId) {#ariaid-title5}

Checks if a personal authentication credential is associated with a specified alias.
{#PerAuth-isPersonalAuthEnabled_S__table_ipa_enb_1__entry__3}

| Name | Type | Description |
|-|-|-|
| aliasId | String | Sys_id of the connection and credential alias to check for an associated personal authentication credential. Table: Connection \& Credential Aliases \[sys_alias\] |
[Table 6. Parameters]

{#PerAuth-isPersonalAuthEnabled_S__table_ipa_enb_1} {#PerAuth-isPersonalAuthEnabled_S__table_ipa_ret_1__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether a personal authentication credential is associated with the specified alias. Possible values: * true: A personal authentication credential is associated with the specified alias. * false: The credential associated with the alias isn't a personal authentication credential, or no credential could be found for the alias. Also returned if aliasId isn't provided or doesn't exist in the sys_alias table. |
[Table 7. Returns]

{#PerAuth-isPersonalAuthEnabled_S__table_ipa_ret_1}  
The following code example shows how to call this method.

    var aliasId = "f4668804ff03221071aaf10303cb1456";
    var personalAuthAPI = new sn_cc.PersonalAuthAPI();
    var result = personalAuthAPI.isPersonalAuthEnabled(aliasId);
    gs.info(result);

Output:

    true

## PersonalAuthAPI - isTokenValid(String aliasId) {#ariaid-title6}

Checks whether a valid access/refresh token exists for the personal authorization credential associated with a specified alias.
{#PerAuth-isTokenValid_S__table_npq_pk2_3bc__entry__3}

| 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\] |
[Table 8. Parameters]

{#PerAuth-isTokenValid_S__table_npq_pk2_3bc} {#PerAuth-isTokenValid_S__table_opq_pk2_3bc__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether there's an associated personal authorization credential for the specified alias ID. Possible values: * true: A valid personal authorization credential exists. * false: A valid personal authorization credential doesn't exist. |
[Table 9. Returns]

{#PerAuth-isTokenValid_S__table_opq_pk2_3bc}  
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) {#ariaid-title7}

Revokes an existing access/refresh token for the personal authentication credential associated with a specified alias.
{#PerAuth-revokeToken_S__table_nsn_nwk_3bc__entry__3}

| 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\] |
[Table 10. Parameters]

{#PerAuth-revokeToken_S__table_nsn_nwk_3bc} {#PerAuth-revokeToken_S__table_osn_nwk_3bc__entry__2}

| 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. * \<object_name\>.getResponseStatus(): Returns the status of the revokeToken() method call, either success or fail. You can find additional information on any error in the error logs. * \<object_name\>.getExpiryInSeconds(): Returns the number of seconds until the associated credential expires. If this value is anything other than zero, the revoke request failed. * \<object_name\>.isAuthenticated(): Returns a Boolean value that indicates whether the personal auth token exists. If the revokeToken() method call was successful, this method should return false. * \<object_name\>.getCredentialId(): Returns the sys_id of the personal authorization credential associated with the token. Located in the OAuth 2.0 Credentials \[oauth_2_0_credentials\] table. |
[Table 11. Returns]

{#PerAuth-revokeToken_S__table_osn_nwk_3bc}  
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


