0
curl -X "GET" "https://chat.twilio.com/v2/Services/ISXXXXX/Channels/CHXXXXX/Messages" \
 -H 'Content-Type: application/x-www-form-urlencoded' \
 -H 'Authorization: Bearer ACCESS_TOKEN' \

I am trying to fetch Twilio chat messages as above but, I am getting

{
"code": 20003,
"detail": "Your AccountSid or AuthToken was incorrect.",
"message": "Authentication Error - No credentials provided",
"more_info": "https://www.twilio.com/docs/errors/20003",
"status": 401
}

I have created the ACCESS_TOKEN programatically with grant roles in given channel. Do I need to pass AccountSid as parameter?

maskapsiz
  • 244
  • 5
  • 23

1 Answers1

0

Twilio developer evangelist here.

Access tokens are only used to authenticate users of the Voice, Video, Conversations and Sync SDKs in the client side (web, iOS and Android).

When authenticating API requests you should use either your Account Sid and Auth Token or an API key and secret.

When authorising with an API key and secret you can add the auth header in curl like this:

curl -X "GET" "https://chat.twilio.com/v2/Services/ISXXXXX/Channels/CHXXXXX/Messages" \
-H 'Content-Type: application/x-www-form-urlencoded' \
-u $TWILIO_API_KEY:$TWILIO_API_SECRET
philnash
  • 70,667
  • 10
  • 60
  • 88
  • Hey philnash, I am looking a way to authenticate with access tokens. https://www.twilio.com/docs/iam/access-tokens I think I shouldn't need API_SECRET. -u $TWILIO_API_KEY:$TWILIO_API_SECRET -> this is basic authentication – maskapsiz Apr 29 '21 at 14:21
  • Access tokens are only used to authenticate users of the Voice, Conversations, Sync and Video SDKs in the clients side (web, iOS or Android). When authenticating API requests you should use either your Account Sid and Auth Token or an [API Key and Secret](https://www.twilio.com/docs/iam/keys/api-key). – philnash Apr 29 '21 at 23:15
  • Okay, I got it! If you add this comment as answer, I can accept! – maskapsiz Apr 30 '21 at 07:26