Accessing basic auth credentials from scheduled job
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2024 08:53 PM
I am trying to access basic auth credentials I created from a scheduled job to be able to access rest end point. I tried to do the following but it is returning null.
var provider = new sn_cc.StandardCredentialsProvider() var credential = provider.getCredentialByID('41cc709cdb144c101bdb5a75dc961990'); var userName = credential.getAttribute("user_name"); var password = credential.getAttribute("password");
When I use the basic auth from rest message it works, so wondering if this is the right way or is there anything else I need to set up.
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2024 09:21 PM - edited ‎10-08-2024 09:24 PM
Yes. It can only work on the discovery_credentials table. I checked on my PDI.
if you want to get it from the sys_auth_profile_basic table, refer below code -
var credGr = new GlideRecord('sys_auth_profile_basic');
credGr.get('6418a4c3830112104dddb329feaad32c'); //Replace with your sys_id
credGr.query();
if(credGr.next()){
gs.print("username "+credGr.username+" password "+credGr.password);
}
Please mark this response as correct and helpful if it assisted you with your question.