What product/components do you use and which version/fix level are you on?
Cumulocity 1011.0.28
Is your question related to the free trial, or to a production (customer) instance?
production
What are you trying to achieve? Please describe it in detail.
Within the microservice SDK, how could we get the username of the user which is calling a Microservice API endpoint?
Thanks!
Hi Kai,
not sure if this is outdated but this is how I did this some years ago in my REST Controller:
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
SecurityUserDetails securityUserDetails = ((SecurityUserDetails)auth.getPrincipal());
securityUserDetails.getUsername();
2 Likes
This is the generic Spring based way to access calling user details. If you prefer using our SDK, or if you want an easy way to use these credentials for API calls you can inject a bean of type ContextService<UserCredentials> and get the details from there.
2 Likes
system
Closed
February 21, 2023, 11:39am
5
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.