
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2020 07:53 AM
I have an outbound rest API integration with google g suite. The authentication uses an "Authorization Code" OAuth Profile. I am looking for help on how to pragmatically refresh the OAuth token before running the outbound REST call.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2020 01:52 PM
Hi Jon,
We did something similar with G Suite. We generated a refresh token from Google OAuth 2.0 Playground, stored it as a system property (refreshToken variable below), and then used this code to obtain a new Access token when needed. 'G Suite Admin SDK' being the name of the OAuth Provider in the Application Registries.
// GlideOAuthClientRequest
var clientRequest = new sn_auth.GlideOAuthClientRequest();
clientRequest.setGrantType('refresh_token');
clientRequest.setRefreshToken(refreshToken);
// GlideOAuthClient
var client = new sn_auth.GlideOAuthClient();
// GlideOAuthClientResponse
var tokenResponse = client.requestTokenByRequest('G Suite Admin SDK', clientRequest);
// GlideOAuthToken
var token = tokenResponse.getToken();
var expiresIn = token.getExpiresIn();
var accessToken = token.getAccessToken();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2020 02:11 PM
Hi
I doing something similar with Workday. I am facing challenges to understand where the above piece of code to get the access token will reside. Will it be it in the OAuth provider under OAuth API script?
Also, is it the complete code or any modifications required?
- I have OAuth provider ready
- REST Message is also ready. Just need to have the access token available for REST MESSAGE to get the required data.
Could you please help?
Regards,
Nirmal