+ Start a Discussion

API refresh_token ERROR (expired access/refresh token)

When trying to refresh my user token via the API i receve the below error, i am trying to test out an integration  work arround for when the integration password is reset / security token expires.

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

I have tried to make the request via Curl and using Postman but receve the same error, as far as i can tell i have all of the appropiate rights set up on my connected app.

connected app
Example Curl request:

curl POST https://eu16.salesforce.com/services/oauth2/token -d "grant_type=refresh_token&client_id=3MVG9f..............................svQ10&client_secret=97E8475611A9...............................096391&refresh_token=lZI..........ZSQ"

I have redacted the sensitive infomation above, but this is the data i am entering:

client_id = This is the Consumer Key taken from the connected app screen

client_secret = This is the Consumer Secret  taken from the connected app screen

refresh_token = This is the user security token (Obtained from settings -> My Personal Infomation -> Reset Security Token) 

Is anyone able to detail what i am doing incorrectly?

Khan AnasKhan Anas (Salesforce Developers) 

Greetings to you!

Your app needs permissions (scope) to have the ability to use refresh tokens.
In Setup > Quick Find > App Manager >, click the "Edit" link for your Connected App and add the scope "Perform requests on your behalf at any time (refresh_token, offline_access)".

Once this has saved (you may have to wait a while), you will be able to change the value for the refresh token policy.

Reference: https://salesforce.stackexchange.com/questions/69161/refresh-token-policy-locked-to-immediatly-expire-token

Also, please refer to below links which might help you further with the above issue.




I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas

@Khan Anas - unfortunatly i allready have that scope assigned but i am still seeing the error.

User-added image

Hi @camelUser, I have the same problem, how did you solve it?
Rodrigo Barão MotaRodrigo Barão Mota
I have the same issue and can't figure it out
Anton WeihardAnton Weihard
the same issue for me. any ways to solve it?
Matt SchofieldMatt Schofield
I'm also experiencing this, even after following documented instructions to the letter. Does anyone have any guidance?