• Owen Millard
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I'm trying to access the API of a sandbox instance using OAuth. 

1. I redirect the user to test.salesforce.com
2. The user confirms access and is redirected back to me
3. I exchange the code for a refreshToken
4. I immediately exchange the refresh_token for a new access_token using this command:

curl -X POST --data 'refresh_token=[refresh token form step 3]&client_id=[my client id]&client_secret=[my client secret]&grant_type=refresh_token' -H 'Accept: application/json' -H 'Sforce-Call-Options: client=fivetran' -H 'Content-Type: application/x-www-form-urlencoded' 'https://test.salesforce.com/services/oauth2/token'

Salesforce replies:

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

How can the token be expired? It was just issued. I have also used this exact same application logic to connect to production salesforce instances successfully (with a different application configuration, and using login.salesforce.com instead of test.salesforce.com).
I'm trying to access the API of a sandbox instance using OAuth. 

1. I redirect the user to test.salesforce.com
2. The user confirms access and is redirected back to me
3. I exchange the code for a refreshToken
4. I immediately exchange the refresh_token for a new access_token using this command:

curl -X POST --data 'refresh_token=[refresh token form step 3]&client_id=[my client id]&client_secret=[my client secret]&grant_type=refresh_token' -H 'Accept: application/json' -H 'Sforce-Call-Options: client=fivetran' -H 'Content-Type: application/x-www-form-urlencoded' 'https://test.salesforce.com/services/oauth2/token'

Salesforce replies:

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

How can the token be expired? It was just issued. I have also used this exact same application logic to connect to production salesforce instances successfully (with a different application configuration, and using login.salesforce.com instead of test.salesforce.com).