メニュー

Expand
ページを評価:

アクセストークンの作成

This guide covers creating Access Tokens for use with the mobile and web Conversations SDK clients. An Access Token is the credential that your SDK client endpoints must use to identify and authenticate themselves with the default Chat Service instance underneath any Conversation.

If you haven't already, please read our guide on Conversations SDK client initialization mechanics, which introduces the need for a generated Access Token.

Your server or backend generates this Access Token when you authenticate a chat Participant in a Conversation. The Conversations SDK client then uses the token to authorize with the underlying Chat Service.

アクセストークンの作成

On your server, you must decide the two following things based on the token request that was sent from the SDK:

  • who the Participant is
  • what they should be allowed to do.

To figure out who the chat Participant is (their identity), you can use your existing login system, session cookies, an API token, or whatever mechanism you use to secure API requests or pages today. Who the chat Participant is and how you authorize their use will vary, depending on your specific application.

Once you determine that the chat Participant should indeed be allowed to access your Conversations application, you can grant that Participant access to Conversations by generating an Access Token as part of your authentication flow. You will then return the token to the user client for use in the Conversations SDK.

When creating an Access Token for Conversation, you will need the following information:

A Twilio Account SID

This is the Account SID of your Twilio account and must be the account in which you have created your Conversations Chat Service. (You can manage your Chat Services in the Twilio Console.)

Chat Service SID

This SID is the unique identifier for a Chat Service instance, where your Participants, Conversations, Messages and other Conversations-related data reside. This is the Chat Service you grant the SDK client access to.

Twilio API Key SID

This is the SID of an API Key created for your Twilio Account, which is used to sign the Access Token cryptographically. You can create these API keys in the console.

Twilio APIシークレット

This is the secret part of the API Key above, also managed in the Twilio console.

Identity

The identity of your chat Participant. For example, user@some-domain.com. For more details around Conversations' use of identity for Chat Participant, please refer to User Identity & Access Tokens.

        
        
        
        

        Optional: TTL (Time To Live)

        Access Tokens are only valid for a period of time, given in seconds. The default is 3600 seconds (1 hour), but we recommend adjusting it to several hours. The maximum TTL for a token is 24 hours.

        Once your client receives an Access Token from your server, you can initialize the Twilio Conversations SDK and start sending and receiving messages, as covered in our guide to Initializing SDK Clients.

        ページを評価:

        ヘルプが必要ですか?

        誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。

              
              
              

              フィードバックくださりありがとうございます!

              We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

              Sending your feedback...
              🎉 Thank you for your feedback!
              Something went wrong. Please try again.

              Thanks for your feedback!

              Refer us and get $10 in 3 simple steps!

              ステップ1

              Get link

              Get a free personal referral link here

              ステップ2:

              Give $10

              Your user signs up and upgrade using link

              ステップ3

              Get $10

              1,250 free SMSes
              OR 1,000 free voice mins
              OR 12,000 chats
              OR more