The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Open URL in background (scheduled script or script include)

Kamil Smusz
Kilo Sage

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

 

9 REPLIES 9

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());

Hi Mike,

 

This one works but only updating access token but my goal is to update refresh token.

 

Kamil

Unfortunately the same story. Script returning only access token without refresh.

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)