Twitter 3-legged authorization in Ruby -


i trying hand ruby on rails. have written code in sinatra. anyway question may not have framework. , question may sound novice question. playing twitter 1.1 apis , oauth first time.

i have created app xyz , registered twitter. got xyz's consumer key i.e., consumer_key , consumer secret i.e. consumer_secret. got xyz's own access token i.e access_token , access secret i.e. access_secret

xyz application type: read, write , access direct messages xyz callback url: http://www.mysite.com/cback , have checked: allow application used sign in twitter

what trying simple:

1) users come website , click link link twitter account (not signin twitter)
2) opens twitter popup user grants permission xyz perform actions on his/her behalf
3) once user permits , popup gets closed, xyz app gets user's access token , secret , save in database.
4) xyz uses user's token , secret perform actions in future.

i may moron such work flow has been implemented on several thousands sites , twitter api documentations explain 3-legged authentication, still unable figure out.

i have read https://dev.twitter.com/docs/auth/3-legged-authorization , https://dev.twitter.com/docs/auth/implementing-sign-twitter unfortunately no ruby code found on internet explains step step example.

what link should used open twitter authentication page when user clicks link twitter account. can here, write pseudo code pseduo credential above achieve goal beging till end of work flow? thanks.

update:

i started requesting request token

require 'oauth'
consumer = oauth::consumer.new(consumer_key, consumer_secret,
{ site: "https://twitter.com"})
request_token = consumer.get_request_token oauth_callback: 'http://www.mysite.com/tauth'
redirect_to request_token.authorize_url

i'm not familiar ror here workflow of oauth 'dance' need follow when user clicks button:

  1. obtain unauthorized request token twitter sending request to

    post https://api.twitter.com/oauth/request_token

    signing request using consumer secret. done in background , transparent user.

  2. you receive oauth_token , oauth_token_secret twitter.

  3. redirect user to

    https://api.twitter.com/oauth/authorize?oauth_token=[token_received_from_twitter]

    using oauth token value received twitter in step 2.

  4. when user authorizes app redirected callback url oauth_token , oauth_verifier appended url. i.e.

    http://www.mysite.com/cback?oauth_token=npcudxy0yu5t3tbzho7icotz3cnetkwctirlx0iwrl0&oauth_verifer=uw7njwht6oj1mpjoxshfnxoahpkpgi8blydhxejiby

  5. convert request token access token sending signed request along oauth_verifier to

    post https://api.twitter.com/oauth/access_token

    signing request consumer secret , token secret received in step 2.

  6. if goes ok, receive new oauth_token , oauth_token_secret twitter. access token user.

  7. using access token , secret received in step 6 can make twitter api calls on behalf the user sending signed requests appropriate api endpoints.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -