2

Problems with REST API access. We are able to authenticate and get a token using the Client Credentials flow, via an Integration user. i.e. the Integration User is specified in the Connected App as the anointed user for Client Credentials flow. I can see in the back-end that login as successful as the correct user.

But once we have the token, all our attempts at REST queries fail with the error "This session is not valid for use with the REST API", while providing the token as Bearer. What could be causing this?

Things I've checked

  • Connected App grants API access
  • Connected App has IP restrictions relaxed
  • User has permissions to query the objects we're attempting to query (and I would expect a different err if object permissions were the problem).

Is there some restriction in using an Integration User in this way? Isn't think what that license type is for?

Thanks!!

2
  • Welcome to SFSE! Please take a moment to read How to Ask and take the tour. Including a Minimal, Complete and Reproducible example would be helpful.
    – identigral
    Commented Sep 29, 2023 at 16:06
  • Looks like the problem is the OAuth flow, not the user. I tried switching to getting the token via Username-Password flow, and it worked. Same user, same Connected App. So is the Client Credentials flow not usable for REST API operations?
    – mscholtz
    Commented Sep 29, 2023 at 18:12

1 Answer 1

-2

Well, if you have done the authentication you are using the REST API since you are making the call to authenticate using the REST API. Likely your issue is that the integration user you are using doesn't have access to the objects and fields you are trying to access.

To see if that is your issue I would try it with an admin user just to see if that works. If it does then you know your issue is the permissions on your integration user.

Integration users start off with almost no access. You need a permissions set (could do it in the profile but we are moving away from putting object/field access there) that allows the minimum needed access to the objects and fields you are trying to get to and if the objects are private you need to handle that with hierarchy or sharing rules.

This is all easier to debug in Postman. here is a trailhead module for Postman if you would like to try things out there. https://trailhead.salesforce.com/content/learn/projects/quick-start-connect-postman-to-salesforce

2
  • A lack of FLS permissions would be a surprising cause of the error "This session is not valid for use with the REST API". Can you connect those dots?
    – David Reed
    Commented Oct 2, 2023 at 0:41
  • Yeah, thanks Ross, but this is not what's going on. Have actually already tried with admin user, no change. And have had a permset assigned to integration user from the start. Really seems to be about which OAuth flow I'm using.
    – mscholtz
    Commented Oct 2, 2023 at 19:32

You must log in to answer this question.

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