- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 09:06 AM - edited 10-10-2023 09:07 AM
Hi all,
I have fetched the access token using a script and I want to update the access token with a new one inside oauth credential table. How I can do it?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 10:03 AM
Hi @Obito,
Access token are stored in oauth_credential to insert the access token manually try below script it would helpful
var response = { "access_token": "ya29.c.b0Aaekm1L2B_W-8A3-Vqfo18k4dTMGihI4EK9KmXgR60q9sVzUMMbc5YWe2k-S3HsPkzLoUAfi2RTblkq-R8k_FAYqpvvQ0rW43mUK86mZpXEZGl5RBwDdqrE-DURhubsKTLdY-d7Fnc-1HTT_ZSOchagZPa5tNTXzQCu8UcFNR5sQqHJyka-D1w-SNcB8XiyKIuUaqZU9SSigbfoSWoy3dKc5vSjLHc2qmdTXYxAzBI1vf8wsD",
"expires_in": 3599,
"token_type": "Bearer" }; //Example response
var oauth = new GlideRecord('oauth_credential');
oauth.initialize();
oauth.peer.name = 'storing_accesstoken';
oauth.token_received = response.access_token;
var gdt = new GlideDateTime();
gdt.addSeconds(response.expires_in);
oauth.expires = gdt.getDisplayValue();
oauth.insert();
If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.
Regards,
T Mohan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 10:03 AM
Hi @Obito,
Access token are stored in oauth_credential to insert the access token manually try below script it would helpful
var response = { "access_token": "ya29.c.b0Aaekm1L2B_W-8A3-Vqfo18k4dTMGihI4EK9KmXgR60q9sVzUMMbc5YWe2k-S3HsPkzLoUAfi2RTblkq-R8k_FAYqpvvQ0rW43mUK86mZpXEZGl5RBwDdqrE-DURhubsKTLdY-d7Fnc-1HTT_ZSOchagZPa5tNTXzQCu8UcFNR5sQqHJyka-D1w-SNcB8XiyKIuUaqZU9SSigbfoSWoy3dKc5vSjLHc2qmdTXYxAzBI1vf8wsD",
"expires_in": 3599,
"token_type": "Bearer" }; //Example response
var oauth = new GlideRecord('oauth_credential');
oauth.initialize();
oauth.peer.name = 'storing_accesstoken';
oauth.token_received = response.access_token;
var gdt = new GlideDateTime();
gdt.addSeconds(response.expires_in);
oauth.expires = gdt.getDisplayValue();
oauth.insert();
If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.
Regards,
T Mohan.