PersonalAuthAPI - Scoped

concept australia Updated Sep 10, 2026 2 min read PersonalAuthAPIScoped.md
Raw file servicenow.com

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.

Parent Topic:Server API reference

PersonalAuthAPI - PersonalAuthAPI()

Instantiates a new PersonalAuthAPI object.

Name Type Description
None

The following code example shows how to instantiate a PersonalAuthAPI object.

JavaScript
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.

JavaScript
var aliasId = "e41b9dd1532102104c4bddeeff7b1250";var personalAuthAPI = new sn_cc.PersonalAuthAPI();var result = personalAuthAPI.getInitiatorURL(aliasId);gs.info(result);

Output:

Text
/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:

  • true: A valid personal authorization credential exists.
  • false: A valid personal authorization credential doesn't exist.
The following code example shows how to call this method.
JavaScript
var aliasId = "e41b9dd1532102104c4bddeeff7b1250"; var personalAuthAPI = new sn_cc.PersonalAuthAPI();  var result = personalAuthAPI.isTokenValid(aliasId); gs.info(result);

Output:

Text
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.- <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.
The following code example shows how to call this method.
JavaScript
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:

Text
SUCCESS0falsed84b5115532102104c4bddeeff7b12f2
Search documentation
Search document titles and file paths on the australia branch