Open URL in background (scheduled script or script include)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2022 09:20 AM
Hello experts,
I working on automation for OAuth authorization and i need to open URL from server site. Next this URL will redirect to new one and return parameter in URL link. Is it possible?
so steps should look like below:
1. open url in background
2. get parameter from redirected url
3. use parameter value in script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2022 11:17 AM
Did you try the second block of code? Grant type = refresh_token
Code to retrieve a new Access Token using Refresh token
var oAuthClient = new sn_auth.GlideOAuthClient();
var requestor_context = 'test';
var requestor_id = 'abc@xyz.com';
var oauth_profile_id = '43d6bab3db849f009a6ff9b61d961957'; // profile ID [sys_id of 'OAuth Entity Profiles' (oauth_entity_profile) record in OAUTH registry record]
var params = {grant_type:"refresh_token", refresh_token:"<value_of_refresh_token>", oauth_requestor_context:requestor_context, oauth_requestor:requestor_id, oauth_provider_profile:oauth_profile_id};
var json = new global.JSON();
var text = json.encode(params);
var tokenResponse = oAuthClient.requestToken('oAuth Test', text); //'oAuth Test' is the name of the OAuth application registry record (oauth_entity)
var token = tokenResponse.getToken();
var access_token = token.getAccessToken() ;
gs.log("AccessToken:" + access_token);
gs.log("AccessTokenExpiresIn:" + token.getExpiresIn());gs.log(" RefreshToken:" + token.getRefreshToken());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2022 11:26 AM
Hi Mike,
This one works but only updating access token but my goal is to update refresh token.
Kamil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2022 11:33 AM
You can try the script provided by Jay Shah3 at the end of this post
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2022 11:44 AM
Unfortunately the same story. Script returning only access token without refresh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2022 12:05 PM - edited 10-21-2022 12:05 PM
Odd, well let's see if anyone else on this forum has any other ideas.
I would also open a case with SN for them to advise on generating the refresh token programmatically. I think your original method of opening the url, grabbing a parameter, and using value in the script is prone to security holes and also could break with future SN upgrades (or even upgrades to the 3rd party app)