Twilio Connect Ruby 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, log in to the Twilio Console and go to Settings > Connect applications. Click Create a new connect app and fill in the top section with the name of your application and your company information.
Next, assign an Authorize URL to your Connect application. The Authorize URL is the URL that Twilio will redirect the user's browser to after they have authorized your application to access their Twilio account. Later on in the quickstart we'll demonstrate how the Authorize URL is used.
Lastly, select the access rights your Connect app requires on the user's account. For this example we will access call logs for analytics, so we'll choose "Read all account data".
Here's what our sample Connect application looks like:

Click Save and you're done!
1require 'rubygems'2require 'sinatra'3require 'twilio-ruby'45get '/connect' do6sid = params['AccountSid']7# Store this account sid in your database, so you can retrieve it8# later. You will need to write this section of the code.910# Finally, redirect the user to your app after you've gathered their Sid11redirect 'http://example.com/myapp'1213end
1require 'rubygems' # not necessary with ruby 1.9 but included for completeness2require 'twilio-ruby'34# Use your customer's account sid.5account_sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'67# Use your own auth token.8auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'910# set up a client to talk to the Twilio REST API11client = Twilio::REST::Client.new(account_sid, auth_token)1213calls = client.calls.list1415begin16calls.each do |call|17puts call.sid + "\t" + call.from + "\t" + call.to18end19calls = calls.next_page20end while not calls.empty?
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 into your applications.