メニュー

Expand
ページを評価:

ユーザーアイデンティティとアクセストークン

The Twilio Conversations API is now Generally Available! We recommend using Conversations to build your chat application to get access to additional channels and even more functionality.

An identity in Chat is unique to a user and may be signed in on multiple devices simultaneously. For example, identity "alice@example.com" will stay synchronized on a number of endpoints including her iPhone, Android tablet and in-browser application. All destinations for the same user will receive identical channel and message notifications as well as display the same message history.

On the server, we must decide, based on the token request that was sent to us, who the user is and what they should be allowed to do. To figure out who the user is (their identity), you might use your existing login system or identity provider (e.g. using session cookies, an API token, or whatever mechanism you use to secure API requests or pages today). You might not care who a user is at all, and assign them a temporary identity as in our starter apps. Who the user is, what is their role, and how you determine that will vary from application to application.

If you determine that the user should indeed be allowed to access your Chat application, you must grant your user access to Chat and supply an identity. Here are the guidelines on how to generate JWT access tokens: Creating Access Tokens.

Programmable Chat also uses identity to track monthly usage and generate accounting reports, therefore be mindful about provisioning a reasonable amount of unique identities. Reusing identities too frequently and keeping uniqueness low may cause conflicts in the user and application logic. On the other end, using only random identities will result in a large number of redundant unique users, which also impacts monthly billing.

Active Users in Chat

Twilio's Programmable Chat tracks unique user identities each month, and each unique identity connecting to a Chat Service will create a User record. During a calendar month, if a user registers activity, they are considered "active." The following activities register users as "active users":

  • User is created via the REST API
  • User is updated via the REST API
  • User authenticates via the SDK
  • User sends a message from the SDK
  • User sends a message from SDK
  • A message is sent on behalf of a user from the REST API
  • User joins a Channel via the SDK
  • User is added to a Channel via REST API or SDK
  • User is invited to a Channel
  • User is removed from a channel via REST or SDK

To minimize costs related to active users:

  • avoid creating the Chat client object (in the SDK) until you are certain that the User wants to read/send messages
  • avoid unnecessary REST API updates to users (e.g., User attributes)

ページを評価:

ヘルプが必要ですか?

誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、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