Accessing basic auth credentials from scheduled job
- 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2024 09:24 PM
Hi @samadam
I tried running the script shared by you on my PDI and it is working as expected both in Global Scope and in a scoped application. I will suggest you to check if you are passing the right sys_id of the credential record. Moreover, check if your Fix Script scope has access to the credential record or not.
Also, you have missed a ; in the first line of your code,
var provider = new sn_cc.StandardCredentialsProvider()
Please add that as well.
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2024 06:12 AM
I checked that and both are in the same scope. Get this error "Cannot convert null to an object."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2024 09:08 AM
Can you please validate the sys_id of the credential record again ? I validated this scenario by passing wrong sys_id and I am able to get the same error.
Copy the sys_id of your credentials by going to discovery_credentials table -> right click on your credential record -> Click copy sys_id
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2024 02:10 PM
The basic auth profile I created is in the "sys_auth_profile_basic" table. Do I need to create a credentials table in the table you mentioned for this to work?