Search in sources :

Example 1 with IpMessagingGrant

use of com.twilio.sdk.auth.IpMessagingGrant in project api-snippets by TwilioDevEd.

the class TokenGenerator method main.

public static void main(String[] args) {
    // Required for all types of tokens
    String twilioAccountSid = "ACxxxxxxxxxxxx";
    String twilioApiKey = "SKxxxxxxxxxxxx";
    String twilioApiSecret = "xxxxxxxxxxxxxx";
    // Required for IP Messaging
    String ipmServiceSid = "ISxxxxxxxxxxxx";
    String deviceId = "someiosdevice";
    String identity = "user@example.com";
    String appName = "HipFlowSlackDockRC";
    String endpointId = appName + ":" + identity + ":" + deviceId;
    // Create IP messaging grant
    IpMessagingGrant grant = new IpMessagingGrant();
    grant.setEndpointId(endpointId);
    grant.setServiceSid(ipmServiceSid);
    // Create access token
    AccessToken token = new AccessToken.Builder(twilioAccountSid, twilioApiKey, twilioApiSecret).identity(identity).grant(grant).build();
    System.out.println(token.toJWT());
}
Also used : IpMessagingGrant(com.twilio.sdk.auth.IpMessagingGrant) AccessToken(com.twilio.sdk.auth.AccessToken)

Aggregations

AccessToken (com.twilio.sdk.auth.AccessToken)1 IpMessagingGrant (com.twilio.sdk.auth.IpMessagingGrant)1