Twilio Connect Java Quickstart
Twilio Connect allows developers to obtain authorization to make calls, send text messages, purchase phone numbers, read access logs and perform other API functions on behalf of another Twilio account holder.
As an example, imagine you want to access the Twilio account of a user of your web application to provide in-depth analytics of their Twilio account activity. This quickstart solves this problem by creating your first Twilio Connect App and placing the "Connect" button on your website so users can authorize your app to access their Twilio account data and make API requests against their account.
To create your first Connect App, follow these steps:
-
Log in to the Twilio Console.
-
Go to Settings > Connect applications.
-
Click Create a new connect app.
-
Complete the top section with the name of your application and your company information.
-
Assign an Authorize URL to your Connect application. After the end user authorizes your application to access their Twilio account, Twilio redirects the end user's browser to this URL.
-
Select the access rights your Connect app requires on the user's account. This example accesses call logs for analytics.
-
Choose Read all account data. The sample Connect application should resemble the following:

-
Click Save.
1import java.util.Map;2import java.util.HashMap;34import com.twilio.sdk.TwilioRestClient;5import com.twilio.sdk.TwilioRestException;6import com.twilio.sdk.resource.instance.Account;7import com.twilio.sdk.resource.instance.Call;8import com.twilio.sdk.resource.list.CallList;910public class CallRetriever {1112// The customer's Account Sid13public static final String ACCOUNT_SID = "AC123";1415// Your own Auth Token16public static final String AUTH_TOKEN = "456bef";1718public static void main(String[] args) throws TwilioRestException {1920TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);21Account mainAccount = client.getAccount();22CallList calls = mainAccount.getCalls();23for (Call call : calls) {24System.out.println("From: " + call.getFrom() + " To: " + call.getTo());25}26}27}28
Retrieving call logs on behalf of your customers is just the start of what you can accomplish with Twilio Connect. Visit the complete Connect documentation and best practices to learn more about how to integrate Connect's additional capabilities to your applications.