2

I have a custom link in Salesforce that passes the session id of the currently logged in user (over HTTPS). I'd like my application to be able to take the session id and look up the username of that user (my application needs to be aware of who the user in Salesforce was).

I know I can use the session id to make authenticated REST calls. Is there a way to get information about the current user?

4
  • Can you pass other values rather than a session id? Why do you only send the session id? Commented Dec 19, 2014 at 15:47
  • A valid session id proves that the user has authenticated. Simply passing in something like their username could be done by any mischievous person. Commented Dec 19, 2014 at 16:16
  • Have you looked at OAuth 2.0? Is it something that you might use? Commented Dec 19, 2014 at 16:23
  • You sure can, but the answer is non-obvious: it's not in the core REST API calls, but instead exists in Chatter. Note that you must also know the server they are coming from in addition to the session ID.
    – sfdcfox
    Commented Dec 19, 2014 at 16:55

1 Answer 1

1

After passing the session ID, you can call the Chatter User API call:

https://[server].salesforce.com/services/data/v[XX.X]/chatter/users/me

Replace [XX.X] with a current version, such as 32.0, and [server] with the correct server for your instance.

Information you'll get back looks like:

{
    "email": "...",
    ...
    "firstName": "...",
    ...
    "id": "005...",
    ...
    "lastName": "...",
    ...
}

Try it out to see all the information you get available, which includes things like the user's manager, user profile images, phone numbers, and more.

There is nothing in the core REST API that presents this data. You'll probably need to enable chatter for your organization (there's no cost for this feature).

1
  • Unfortunately we don't have a use for Chatter at my organization so it's disabled. From the looks of it, enabling it changes quite a few things which is something that would require some time, thought and input from my users. Commented Dec 19, 2014 at 18:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .