---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# GlideOAuthToken - Scoped, Global

# GlideOAuthToken - Scoped, Global {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

The GlideOAuthToken API provides methods for retrieving OAuth access
token and information about the access token.

You can use this API in global and scoped scripts. In scoped scripts use the
`sn_auth` namespace identifier.

## GlideOAuthToken - getAccessToken() {#ariaid-title2}

Retrieves the access token associated with the GlideOAuthToken object.
{#r_GlideOAuthTokenGetAccessToken__table_qc4_bzf_cr__entry__3}

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

{#r_GlideOAuthTokenGetAccessToken__table_qc4_bzf_cr} {#r_GlideOAuthTokenGetAccessToken__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| String | Access token. |
[Table 2. Returns]

{#r_GlideOAuthTokenGetAccessToken__table_rc4_bzf_cr}  
This example code shows how to retrieve access and refresh tokens from the instance
database. See also [GlideOAuthClient](https://servicenow-prod.fluidtopics.net/s2YIPZ~JpzO4KvVYsmJJHA#c_GlideOAuthClient "The GlideOAuthClient API provides methods for requesting and revoking OAuth refresh and access tokens.").

    function dumpToken(token) {
      if(token) {
         gs.info("AccessToken:" + token.getAccessToken());
         gs.info("AccessTokenExpiresIn:" + token.getExpiresIn());
         gs.info("RefreshToken:" + token.getRefreshToken());
      }
    }

    var oAuthClient = new  sn_auth.GlideOAuthClient();
    var token = oAuthClient.getToken('248e3017c302301089a7dd5c2840dda5', '9c4e78d3c302301089a7dd5c2840dd76');
    dumpToken(token);

Output:

    *** Script: AccessToken:6MRxD3TRYYvIaoKr-JCy3KiaOxBPu4C9k8oafo3MYf9q8zDyHQr8UzMSM3Md2alfaES1rzSYe5ydqgbOwpm7TA
    *** Script: AccessTokenExpiresIn:1207
    *** Script: RefreshToken:sc0iTK-0PcVkRi14HXPM3vT0FyOPO8iCqC10huQoDSSLBGUSnmEv_fUfJzGWCWBb_StsXIOz6r8qF-hRhURWTA

## GlideOAuthToken - getAccessTokenSysID() {#ariaid-title3}

Deprecated. Retrieves the sys_id of the token ID associated with the GlideOAuthToken
object.
{#r_GlideOAuthTokenGetAccessSysID__table_qc4_bzf_cr__entry__3}

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

{#r_GlideOAuthTokenGetAccessSysID__table_qc4_bzf_cr} {#r_GlideOAuthTokenGetAccessSysID__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| String | Sys_id of the access token. |
[Table 4. Returns]

{#r_GlideOAuthTokenGetAccessSysID__table_rc4_bzf_cr}

## GlideOAuthToken - getExpiresIn() {#ariaid-title4}

Retrieves the lifespan of the access token associated with the GlideOAuthToken
object.
{#r_GlideOAuthTokenGetExpiresIn__table_qc4_bzf_cr__entry__3}

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

{#r_GlideOAuthTokenGetExpiresIn__table_qc4_bzf_cr} {#r_GlideOAuthTokenGetExpiresIn__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| Number (Long) | Lifespan of the token. Unit: Seconds |
[Table 6. Returns]

{#r_GlideOAuthTokenGetExpiresIn__table_rc4_bzf_cr}  
This example code shows how to retrieve access and refresh tokens from the instance
database. See also [GlideOAuthClient](https://servicenow-prod.fluidtopics.net/s2YIPZ~JpzO4KvVYsmJJHA#c_GlideOAuthClient "The GlideOAuthClient API provides methods for requesting and revoking OAuth refresh and access tokens.").

    function dumpToken(token) {
      if(token) {
         gs.info("AccessToken:" + token.getAccessToken());
         gs.info("AccessTokenExpiresIn:" + token.getExpiresIn());
         gs.info("RefreshToken:" + token.getRefreshToken());
      }
    }

    var oAuthClient = new  sn_auth.GlideOAuthClient();
    var token = oAuthClient.getToken('248e3017c302301089a7dd5c2840dda5', '9c4e78d3c302301089a7dd5c2840dd76');
    dumpToken(token);

Output:

    *** Script: AccessToken:6MRxD3TRYYvIaoKr-JCy3KiaOxBPu4C9k8oafo3MYf9q8zDyHQr8UzMSM3Md2alfaES1rzSYe5ydqgbOwpm7TA
    *** Script: AccessTokenExpiresIn:1207
    *** Script: RefreshToken:sc0iTK-0PcVkRi14HXPM3vT0FyOPO8iCqC10huQoDSSLBGUSnmEv_fUfJzGWCWBb_StsXIOz6r8qF-hRhURWTA

## GlideOAuthToken - getRefreshToken() {#ariaid-title5}

Refreshes the token associated with the GlideOAuthToken object.
{#r_GlideOAuthTokenGetRefreshToken__table_qc4_bzf_cr__entry__3}

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

{#r_GlideOAuthTokenGetRefreshToken__table_qc4_bzf_cr} {#r_GlideOAuthTokenGetRefreshToken__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| String | Refreshed token. |
[Table 8. Returns]

{#r_GlideOAuthTokenGetRefreshToken__table_rc4_bzf_cr}  
This example code shows how to retrieve access and refresh tokens from the instance
database. See also [GlideOAuthClient](https://servicenow-prod.fluidtopics.net/s2YIPZ~JpzO4KvVYsmJJHA#c_GlideOAuthClient "The GlideOAuthClient API provides methods for requesting and revoking OAuth refresh and access tokens.").

    function dumpToken(token) {
      if(token) {
         gs.info("AccessToken:" + token.getAccessToken());
         gs.info("AccessTokenExpiresIn:" + token.getExpiresIn());
         gs.info("RefreshToken:" + token.getRefreshToken());
      }
    }

    var oAuthClient = new  sn_auth.GlideOAuthClient();
    var token = oAuthClient.getToken('248e3017c302301089a7dd5c2840dda5', '9c4e78d3c302301089a7dd5c2840dd76');
    dumpToken(token);

Output:

    *** Script: AccessToken:6MRxD3TRYYvIaoKr-JCy3KiaOxBPu4C9k8oafo3MYf9q8zDyHQr8UzMSM3Md2alfaES1rzSYe5ydqgbOwpm7TA
    *** Script: AccessTokenExpiresIn:1207
    *** Script: RefreshToken:sc0iTK-0PcVkRi14HXPM3vT0FyOPO8iCqC10huQoDSSLBGUSnmEv_fUfJzGWCWBb_StsXIOz6r8qF-hRhURWTA

## GlideOAuthToken - getRefreshTokenSysID() {#ariaid-title6}

Deprecated. Retrieves the sys_id of the refresh token.
{#r_GlideOAuthTokenGetRefreshTokenSysID__table_qc4_bzf_cr__entry__3}

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

{#r_GlideOAuthTokenGetRefreshTokenSysID__table_qc4_bzf_cr} {#r_GlideOAuthTokenGetRefreshTokenSysID__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| String | Sys_id of the refresh token. |
[Table 10. Returns]

{#r_GlideOAuthTokenGetRefreshTokenSysID__table_rc4_bzf_cr}

## GlideOAuthToken - getScope() {#ariaid-title7}

Retrieves the token scope, which is the amount of access granted by the access
token.
{#r_GlideOAuthTokenGetScope__table_qc4_bzf_cr__entry__3}

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

{#r_GlideOAuthTokenGetScope__table_qc4_bzf_cr} {#r_GlideOAuthTokenGetScope__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| String | Scope of the access token. |
[Table 12. Returns]

{#r_GlideOAuthTokenGetScope__table_rc4_bzf_cr}

