0

I am a front-end dev trying to hook a salesforce api to one of my apps.

For practice (yesterday) I created a new connected app and used the below to fetch some data and it worked

curl https://tahina-test2-dev-ed.my.salesforce.com/services/data/v20.0/sobjects/Order/8012Xff0004qzjPQAQ?fields=Status -H 'Authorization: Bearer 00D2X000001bhbhlTPnqeFBF7WSQdKKX9nKdr_oyTpajKccG5EZ03jtJJu7BS2tv2oLWhuwrc2V9WOv3tuOFHyJ0cuq8PA4rn1' -H "X-PrettyPrint:1"

But today this below error when i try to fetch the data with the same curl request

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

can anyone help me understand how to avoid this and keep fetching my data as yesterday?

1 Answer 1

0

You need to get the updated token, which is present after Bearer word.

You can request token by another curl call (for sandbox replace login word with test) -

curl -v https://login.salesforce.com/services/oauth2/token 
      -d "grant_type=password" -d "client_id=consumer_key" 
      -d "client_secret=consumer_secret" 
      -d "username=username" -d "password=password"
4
  • I tried this by replacing consumer_key, consumer_secret, username of my account and password and got "error": "invalid_grant", "error_description": "authentication failure
    – Kisho
    Commented Jul 1, 2020 at 15:44
  • if you have security token add with password
    – Ysr Shk
    Commented Jul 1, 2020 at 16:44
  • sorry can you elaborate?
    – Kisho
    Commented Jul 1, 2020 at 18:05
  • typically we do have a concept of security token. If you change your password, it'll send you a new security token.You need to add/append with password. E.g. password is 123 then you need to add after "123<token>" as a password
    – Ysr Shk
    Commented Jul 2, 2020 at 3:46

You must log in to answer this question.

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