Closed ananth10 closed 7 years ago
@ananth10 here is an example:
final String key = "john.doe@gmail.com";
final String jwtToken;
// Create Conversations messaging grant
ConversationsGrant grant = new ConversationsGrant();
grant.configurationProfileSid = VIDEO_CONFIGURATION_SID;
AccessToken token = new AccessToken.Builder(ACCOUNT_SID, API_KEY, API_SECRET)
.identity(key)
.grant(grant)
.build();
jwtToken = token.toJWT();
The above uses the user-email (for identity) and your twilio credentials (account sid, api key and api secret as well as the video configuration sid - those are all available/can be generated in your twilio account) to generate a token. The above code uses the twilio SDK on the server-side (Java). Please checkout the docs for additional details: https://www.twilio.com/docs/api/video/identity
@FranziscaZarrai . Thank you for the answer . by the way where did you get above code? and is it possible to connect from one useremaid(e.g Identity A) to other useremailId(e.g Identity B) directly without entering into room concept? . because i want to make 1:1 video call.
@ananth10 the code was taken from our own project and slightly modified for simplicity's sake.
As for your question regrding direct connection of the two users: I don't think the twilio SDK provides that option, since it's centered around the concept of rooms.
What you can do instead (and that's pretty much what we do) is equate a room name to a user identity, i.e. if a user has an email john.doe@gmail.com then once the app starts, have him auto-join that room. Provide a list of all online users (you'll need to keep a reference to their emails as well) and have the caller pick from that list (or directly enter the target user's email - whatever works better for you). Now the caller would connect to a room with the name "john.doe@gmail.com" - due to that our original john doe would get a notification, that someone joined his room, which you could display as an "incoming call". And if john doe decides to answer the call you can show the call screen, where both parties are connected. The call screen is basically provided by the quickstart project from twilio here on this repository.
Thanks @FranziscaZarrai for answering the original question! I will close this ticket and any additional questions about 1:1 Video Calling can continue in #74
@ananth10 One additional comment. Here is a slightly updated snippet that shows adding a VideoGrant
instead of ConversationsGrant
. For more information, see our complete guide User Identity and Access Tokens
final String key = "john.doe@gmail.com";
final String jwtToken;
// Create Video grant
VideoGrant videoGrant = new VideoGrant();
videoGrant.setConfigurationProfileSid(VIDEO_CONFIGURATION_SID);
AccessToken token = new AccessToken.Builder(ACCOUNT_SID, API_KEY, API_SECRET)
.identity(key)
.grant(grant)
.build();
jwtToken = token.toJWT();
@aaalaniz . Thank you for the info.
I need to generate AccessToken programmatically and like to set user-email as Identity . Can any one tell me how to do it?