{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":40603,"path":"platform-security/authentication/personal-oauth-token.md","title":"Get Personal OAuth Token \\(using GlideOAuthClient\\)","bundle":null,"doc_type":null,"release":"australia","body":"\n# Get Personal OAuth Token \\(using GlideOAuthClient\\)\n\nCheck whether the user has a personal OAuth token. Use it to confirm valid access before running REST steps or integrations that require personal OAuth credentials.\n\n## Before you begin\n\nRole required: oauth\\_admin\n\n## About this task\n\nUse the `GlideOAuthClient` API to check if a personal OAuth token exists for the currently logged-in user. You can also use `ScopedPersonalAuthAPI` to get the personal OAuth token. For more information, see [PersonalAuthAPI - Scoped](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/api-reference/server-api-reference/PersonalAuthAPIScoped.md).\n\n## Procedure\n\n1.  Use the following sample script to check for a personal access token associated with the current session user:\n\n    ```\n    function dumpToken(token) {\n      if (token) {\n        gs.info(\"Access token: \" + token.getAccessToken());\n        gs.info(\"Expires in: \" + token.getExpiresIn());\n        gs.info(\"Refresh token: \" + token.getRefreshToken());\n      }\n    }\n    \n    var oAuthClient = new sn_auth.GlideOAuthClient();\n    oAuthClient.setPersonal(true); // Returns the token for the logged-in user\n    \n    var token = oAuthClient.getToken('<credential_sys_id>', '<oauth_profile_sys_id>');\n    dumpToken(token);\n    ```\n\n2.  Replace `<credential_sys_id>` and `<oauth_profile_sys_id>` with the appropriate record values.\n\n    The `setPersonal(true)` method confirms that the token returned belongs to the currently logged-in user.\n\n    **Note:** For more information on the methods for requesting and revoking OAuth refresh and access tokens, see: [Glide OAuth Client API Documentation](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/api-reference/server-api-reference/c_GlideOAuthClient.md).\n\n\n"}}