- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 08:34 AM
I would like to know if there is a way via script to find if the existing OAuth token is still valid or expired ?
Currently we have API calls that fetch the Access token, and we have refresh token grant flow that will get us a new access token when the previous access token expires. So before refreshing the token, we would like to know if its possible to somehow check if the current access token is still valid or not.
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 08:35 AM
Try using this code snippet.
auth_value = "Your Token Value";
var result = GlideUser.authenticateOAuthAccessToken(auth_value);
if (!result) {
gs.log("Oauth authentication failed for access token: " + auth_value);
else{
gs.log("The given OAuth token is Valid");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 08:35 AM
Try using this code snippet.
auth_value = "Your Token Value";
var result = GlideUser.authenticateOAuthAccessToken(auth_value);
if (!result) {
gs.log("Oauth authentication failed for access token: " + auth_value);
else{
gs.log("The given OAuth token is Valid");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 08:42 AM
It worked, thank you Aman.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2020 05:04 AM
I am trying to check my access token's validity by passing accesstoken details as shown below..
auth_value = "xveEwG8xMC0feu2gBiwjXtKjBbuCRrrrIsSzmvogu97X-9jH6nEiZmTRK2w0EaXINi1tXSsqWT5pNWmS5ZYUrQ"; // valid access token
var result = GlideUser.authenticateOAuthAccessToken(auth_value);
if (!result) {
gs.log("Oauth authentication failed for access token: " + auth_value);}
else{
gs.log("The given OAuth token is Valid");
}
o/p : is alwasy the same.. can u please help here, am i missing anything here
Oauth authentication failed for access token xveEwG8xMC0feu2gBiwjXtKjBbuCRrrrIsSzmvogu97X-9jH6nEiZmTRK2w0EaXINi1tXSsqWT5pNWmS5ZYUrQ. No user found.
*** Script: Oauth authentication failed for access token: xveEwG8xMC0feu2gBiwjXtKjBbuCRrrrIsSzmvogu97X-9jH6nEiZmTRK2w0EaXINi1tXSsqWT5pNWmS5ZYUrQ
Thanks