How to identify the user who invoked the service
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
How to identify the user who invoked the service
Hi,
How to identify the user who invoked the service?
One option I'm aware of is based on the appKey
var loggedInUser = Resources["CurrentSessionInfo"].GetCurrentUser();
with this approach, I had to create an appKey for each user.
What other options are available? If i didn't want to generate a new appKey for every user.
Regards
Arunkumar D
Solved! Go to Solution.
- Labels:
-
Security
- Tags:
- authentication
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Nope.
If we invoke the service using appKey, GetCurrentUser() would give the user associated with that appKey.
Anyway, one another approach I found to identify the user is to use Authorization header. Like below:
curl -X POST -u username:password -H "Accept:application/json" -H "Content-Type:application/json" "http://hostname/Thingworx/Things/TestThing/Services/TestAPI"
I find this approach would fit me for now, instead of creating an appKey for every user.
Regards
Arunkumar D
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Resources["CurrentSessionInfo"].GetCurrentUser() doesn't depend on appkeys; it returns whoever the current user is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Nope.
If we invoke the service using appKey, GetCurrentUser() would give the user associated with that appKey.
Anyway, one another approach I found to identify the user is to use Authorization header. Like below:
curl -X POST -u username:password -H "Accept:application/json" -H "Content-Type:application/json" "http://hostname/Thingworx/Things/TestThing/Services/TestAPI"
I find this approach would fit me for now, instead of creating an appKey for every user.
Regards
Arunkumar D