You need to sign in to do that
Don't have an account?
jbowes
Find current user via REST api
I'm using OAuth and the REST API from a Rails app, and would like to query the User record for the currently logged in user. I don't see anything in the documentation about this, does anyone know if it's possible to either get info on the currently logged in user?
Part of the oauth response is an Id field, this is a URL to the user's identity service, it contains a number of peices of info, if that's not enough, you can then take the userId from that response and fetch the full user resource.
Hi,
I am also trying to find the current logged in user using the REST API in a SalesForce Hybrid App. I have the session id. In my case, the id field in the OauthCredentials response shows up as undefined. I can only see the AccessToken and the instanceURL fields in the OAuth response. I just need the current logged in username. Can someone please help?
Thanks you.
I ended up having to authenticate the user again using the session id in order to get the full oauth response with the User Id, and then in some cases querying that user yet again to get more values from the User record. It's not very efficient but I haven't seen a better way.
Hi,
Thank you for your reply. I was wondering if you have any source code to pass onto me. Did you re-authenticate using the Rest API or the forcetk client? This is kind of an urgent issue, so any help will be greatly appreciated.
Thanks,
Jayram
I guess I used the databasedotcom Ruby gem for this. The readme in the github repo has an example of using its authenticate method with an oauth token that you got somewhere else, but you can use the session id the same way. It would look something like this: