GlideOAuthClient requestTokenByRequest failed to find the oauth entity
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2016 01:32 AM
Hi
I'm trying create schedule job that generate CSV and upload it to Google drive via Google REST API but I'm having problem getting access and refresh token from the script
below are my Oauth Provider settings
I use the code below for tokens generation but the script return null on all token and 'Error:failed to find the oauth entity' error message
/******************************************************************************/
var tokenRequest = new sn_auth.GlideOAuthClientRequest();
var oAuthClient = new sn_auth.GlideOAuthClient();
var tokenResponse = oAuthClient.requestTokenByRequest('Google Drive default_profile',tokenRequest);
gs.log("Error:" + tokenResponse.getErrorMessage());
var token = tokenResponse.getToken();
gs.log("AccessToken:" + token.getAccessToken());
gs.log("AccessTokenExpiresIn:" + token.getExpiresIn());
gs.log(" RefreshToken:" + token.getRefreshToken());
/******************************************************************************/
Most of the example I found are using the password flow.
I have already Authorize the API via 'Get OAuth Token' link from REST Message module
I based the code on this example How to setup OAuth2 authentication for RESTMessageV2 integrations
p/s I'm new actually new to Oauth so I may have the entire concept wrong.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2016 03:52 PM
"I have already Authorize the API via 'Get OAuth Token' link from REST Message module"
if you ready did that, the token is issued to you and you shall use REST API to get data from Google. check
RESTResponseV2 API - ServiceNow Wiki
You don't need to use " sn_auth.GlideOAuthClient" to get oauth access token again.