- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2021 02:21 AM
Hello all,
i'm using scripted REST API where i will recieve request from external client, the authentication i'm going to use is basic authentication with username and password.
Is there a way to get the username that the client will use to access my API using basic authentication?
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2021 02:56 AM
it will give the logged in user, When someone is accessing your api, they have a logged in user which will have a session, at that time it gs.getuser will give the username credential used to access the api.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2021 02:42 AM
This should be known by the ServiceNow team while they shared the endpoint and credentials to 3rd party.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2021 02:47 AM
I want to make it generic to any user use the API so i can get the username credential from scripted REST API using javascript.
the 3rd party using user that i've created for them on our live instance...but maybe in the future another 3rd party use the same API for creating incident for example, so i want to make it gerenic to check who is the username and based on it do some logic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2021 02:50 AM
Hi,
try to use this to know the user_name or sys_id
gs.getUserName()
OR
gs.getUserID()
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2021 02:51 AM
but this will get my logged in user not the requester user, right?