2

I'm using the Salesforce REST API along with OAuth 2.0 User-Agent Flow. I have the need to "ping" Salesforce to see if a user is logged on (this is the simplest way to do so in my application). If the result returns a 401 status code, I know I need to log them back on.

The "ping" is a simple SOQL request: select id from account limit 1

I'm concerned that there may be a case where a user does not have access to query the Account object, and therefore the query may fail. Is there a object query, metadata request, etc I could perform that is always guaranteed accessible to the user, regardless of permission settings? (i.e. some universal object that the user has to be able to read)

Salesforce version 31.0

2 Answers 2

4

You could request one of the more basic REST resources, such as Versions or Limits.

If they have API access then there will always be a resource for a valid Session.

1
  • 1
    i did some testing and /services/data/v50.0/limits counts towards rest request limits (ironically) /services/data/ doesn't seem to
    – NSjonas
    Dec 5, 2020 at 7:07
1

If want to avoid the "ping" counting towards the API Requests limit, you may be able to use:

/services/oauth2/userinfo

In this related answer, the author tested and confirmed it doesn't count towards the limit.

This endpoint may only be available via oAuth generated tokens with the proper scope.

You must log in to answer this question.

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