Get Access Token from Application Registry using script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 12:50 PM
Hi,
I am having a little trouble with a script to get a new access token from the Application Registry. This registry is created from the BeyondTrust Privileged management plugin, so the application registry was created through that.
I tried to use the information from the below url, but I get the error "ClientType: client is not supported"
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0791131
The application registry does not have an entity profile and I can't add one. Here is a screenshot of my registry.
Can anyone help me with this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 01:42 PM
Hi, it looks like 'BeyondTrust Privileged management plugin' is a store app so cannot be easily installed on a PDI for review\testing. If this is a store app and you have not made any changes to the configuration? Then my expectation would be that it functioned OOB and based on details in your post I would engage the app vendor as there seems to be a mismatch with the grant type.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 01:50 PM
BeyondTrust says that we can automate it, they gave me a word document but it is using Postman to get the access token and I need to use a script within flow designer action to get the access token. I am having a hard time with the script to do it and since the access token expires every 30 minutes, I need to figure out a script. I know this works because they use it in a script include. The problem is I can't see their OOB script include as the script section does not display. It is private.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 03:47 PM
Hi, if the vendor has a script-include to deliver this functionality then they should be able to clarify how you trigger\call it correctly. Perhaps you can you share details of the word doc\Postman configuration so that the community can review?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 03:52 PM - edited 05-01-2024 04:06 PM
Thank you for your help. I was able to use Postman to get the initial access token, but of course it expired after 30 minutes. So I am trying to figure out how I can retrieve a new token without having to go into Postman. If this can be done in ServiceNow possible through a Flow action.
I am working on a rest message to trigger, but I keep getting access denied, server error.
var body = "grant_type=password&username=[username]&password=[password]&client_id=[client id]&client_secret=[client secret]";
var r = new sn_ws.RESTMessageV2();
r.setEndpoint("https://[instance].service-now.com/oauth_token.do");
//r.setRequestHeader("Accept", "application/json");
r.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
r.setRequestBody(body);
r.setHttpMethod('POST');
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.log(responseBody);