Unable to find any documentation on obtaining the logged in User's Id from the Salesforce Mobile SDK for React Native.

In apex the following would work:

select Id, username from User where Id = :UserInfo.getUserId()

And the network { net } import for salesforce mobile sdk can handle queries, but it cannot understand UserInfo.getUserId().

Mobile SDK Docs: https://resources.docs.salesforce.com/sfdc/pdf/mobile_sdk.pdf

Any help is appreciated, thanks!

Based on SFDCFox's answer, how would I capture the this Id endpoint URL from the follow authentication:

    componentDidMount() {
      var that = this;
          () => that.fetchData(), // already logged in
          () => {
                  () => that.fetchData(),
                  (error) => console.log('Failed to authenticate:' + error)

fetchData() {
  var that = this;
  net.query('SELECT Id, Name, Email, Phone FROM User LIMIT 10',
            (response) => that.setState({data: response.records})

1 Answer 1


When you log in with the Mobile SDK, your auth callback will include an identity URL in the id attribute. It'll look something like https://login.salesforce.com/id/00D.../005.... You can then query this URL directly to get a ton of user details. You can read more about it in the documentation. There's no specific SOQL call you can use, but it's not necessary, since there is an alternative method.

  • Thanks! I thought it would have the Id in the response, didn't expect it to be an endpoint though. This may be off-topic, but I have added the authentication code, how would I capture that response given callback function fetchData() above?
    – S.B.
    Sep 9, 2018 at 2:31
  • 1
    @S.B. I'm not particularly a mobile developer, I just know enough to be marginally dangerous. I think a normal XMLHttpRequest could be used on it, though.
    – sfdcfox
    Sep 9, 2018 at 2:55

You must log in to answer this question.

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