Please excuse our look. We're just getting started here.
Want to learn more about Twilio Forums? Check out our FAQ page here.How to create an access token chat for conversation with golang?

I can not found rest api for create access token chat for conversation. I build backend my app with golang and need to gen access token chat for sending to client
Best Answer
-
Hi again @thaibui , the following links might provide you with some clarity.
There’s an example on how to create Access tokens here: https://github.com/twilio/twilio-go#building-access-tokens However, the code snippet is built for Voice. In order to use it for conversations, they should import the Chat Grant and initialize it with the Conversation Service Sid.
Here's a code snippet for your reference:
accountSid := os.Getenv("TWILIO_ACCOUNT_SID") chatServiceSid := os.Getenv("TWILIO_CHAT_SERVICE_SID") apiKey := os.Getenv("TWILIO_API_KEY") apiSecret := os.Getenv("TWILIO_API_SECRET") identity := "user_identity" params := jwt.AccessTokenParams{ AccountSid: accountSid, SigningKeySid: apiKey, Secret: apiSecret, Identity: identity, } jwtToken := jwt.CreateAccessToken(params) chatGrant := &jwt.ChatGrant{ ServiceSid: chatServiceSid, } jwtToken.AddGrant(chatGrant) token, err := jwtToken.ToJwt()
Also, Check out this link: https://www.twilio.com/docs/iam/access-tokens?code-sample=code-creating-an-access-token-conversations&code-language=Python&code-sdk-version=7.x where you can create short-lived Access Tokens to authenticate Twilio Client SDKs like Voice, Conversations, and Video.
I hope this helps! ✨
Answers
-
@sbrijmohan Can you help me ?
-
Hi @thaibui , let me reach out to our support team and see what I can do. Thank you for your patience!
-
Thank you. I will try it
Categories
- 83 All Categories
- 19 SIGNAL 2021
- 376 Product Discussions
- 7 Community - Announcements
- 2 Changelog
- 4 Forum UI Updates
- 8 Welcome Guide
- 6 Community - Events
- 2 Twilio Relay Developer Conference 2021 Mega Thread
- 1 External Community Events
- 25 Inspiration
- 17 Community - Other Discussions
- 1 Community- Twilio Startups