How to use pass caller credentials (Basic Auth) from one API to another?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2022 05:25 AM
I have a custom Scripted REST API that uses Basic Authentication (user ID and password). This scripted API is calling an out of the box API that also uses Basic Authentication.
Is there a way I can set the Basic Authentication values when calling the out of the box API, using the credentials that were used to call the scripted API?
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2022 06:23 AM
Hi
in your REST API Script check whether you can get the original request header "Authorization"
request.getHeader('Authorization');
Then use that value to set a corresponding header for the next REST call.
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2022 03:35 AM
Hi
In case you think I was able to answer your question, I would be happy if you mark the appropriate response as "correct" so that the question will appear as resolved for other users who may have a similar question in the future.
If not, please tell me what you are still missing!
Many thanks & kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 09:20 PM
Hi
Did you got the solution for passing the basic auth from one API to another?
In my implementation, I am calling the OOB record producer API from a custom API. The basic auth details received in the custom API is forwarded as it is received to the OOB record producer API. But I can see some sort of encoding is happening to the password other than the base 64 encoding when it is received at the serviceNow end. The OOB record producer API expects the Basic username:password in base 64 encoded format, but as the password is again encoded ,the OOB API, doesn't identifies the user and it is showing the record's created by as guest.
Please help me know, if you got any solution.