0

In my custom rest resource, I want to identify the user who made the API call. Since API call includes Authorization header with access token, can I get the user from this value?

3

Just use the UserInfo class, which:

Contains methods for obtaining information about the context user.

Specifically, you can get their Id, Name, Username, etc.

Id runningUserId = UserInfo.getUserId();
String runningUserName = UserInfo.getName();
String runningUserUsername = UserInfo.getUsername();
  • Thanks Andrian, I posted the question without trying it. My bad. – vishesh Jan 27 '17 at 4:01
0

It works just like controllers.

UserInfo.getuserId() does the job

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.