I'm having an issue where when I use an app in my developer's instance everything works fine.

But when we create an exact duplicate of the app in our real production instance, the token's we are using aren't valid even immediately after getting them. This includes both the OAuth token and the refresh token.

When trying to use the OAuth token, we get this error.

[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]

And then when trying to use our refresh token, we then get this error.

{"error_description":"expired access/refresh token","error":"invalid_grant"}

I've done quite a bit of searching and this answer seems to be the closest thing I can figure to an answer, but these options are no longer in the manage app section of Salesforce.

invalid_grant-expired access/refresh token error when authenticating access via REST

Here is our settings page for the app. It's identical in both development and production.

http://i.imgur.com/0BGjCcC.jpg Salesforce app

I'm stumped as to what else I can change to make this work. It can't be the code if it works in one place and not in another, as far as I can tell.

Thanks in advance for your help.

  • I would check client key/secret and all URLs. Invalid session ID on the 1st call = your token is not valid for (possibly) one of the above reasons. – identigral Jun 29 '15 at 18:52
  • Well, the oauth process goes through fine, so I'm not sure it's the key/secret or URL. Any of those being incorrect have led to the OAuth process not even working previously. – Scheda Jun 29 '15 at 18:53
  • Other things to check - admin pre-approved vs self-authorize and if the former, perm sets and profiles on the connected app. +IP restrictions – identigral Jun 29 '15 at 19:04
  • Unfortunately those are set correctly as well. So, not really sure what's going on here. Sigh. Thanks though! – Scheda Jun 29 '15 at 19:17
  • Is it possible that you are obtaining the token from the Sandbox endpoint (test.salesforce.com) and trying to use it in production? That's about the only thing I can think of that would result in this behavior. – metadaddy Jul 1 '15 at 0:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.