I want to update Refresh Token automatically.

yyuu
Tera Contributor

I am using Graph Spoke to handle sending notifications from Flow Designer to Teams.
There is one problem as I do this.
As I do this, there is one problem: when the Refresh Token expires, it is no longer available.
So I am wondering if I can use Scheduled Jobs to get the Refresh Token automatically.
If anyone has any knowledge on how to do this, I would appreciate it.

 

By the way, I have setup the following link and am using OAuth 2.0.

https://docs.servicenow.com/bundle/rome-servicenow-platform/page/administer/integrationhub-store-spo...

 

Best regards

3 REPLIES 3

Hayo Lubbers
Kilo Sage

If you have the correct source, it should be possible via the GlideOAuthClient().

 

Regards,

Hayo

 

Please mark as correct answer if this solves your issue.

Thank you for your reply.
I was able to get the Token value using GlideOAuthClient(), but when I check the 'oauth_credential' table, it is not updated.
How should I set the value?

I have the name of the oauth_entity as first parameter when doing a requestToken().

 

Where grOEP is a oAuth entity profile (oauth_entity_profile) and profileId the sysId.

The requestor_context is in my case a rest message (value : "sys_rest_message")

And the oauth_requestor the sysId of the rest message. In your case you need to find your definition / link to the oAuth token which is generated.

 

And the jsonParams a json encoded list of parameters. In case of a refreshToken:

var params = {
grant_type: "refresh_token",
refresh_token: new global.AzureDecodeVariables().getDecryptedValue(grOC.token_received),
oauth_requestor_context: requestor_context,
oauth_requestor: requestor_id,
oauth_provider_profile: profileId
};

var tokenResponse = oAuthClient.requestToken(grOEP.oauth_entity.name, jsonParams);

 

Regards,

Hayo

 

Please mark as correct answer if this solves your issue.