Function egg_mode::request_token [] [src]

pub fn request_token<S: Into<String>>(
    con_token: &KeyPair,
    callback: S
) -> Result<KeyPair<'static>, Error>

With the given consumer KeyPair, ask Twitter for a request KeyPair that can be used to request access to the user's account.

Access Token Authentication

Authentication overview

  1. Request Token: Authenticate your application
  2. Authorize/Authenticate: Authenticate the user
  3. Access Token: Combine the authentication

Request Token: Authenticate your application

To begin the authentication process, first log your request with Twitter by authenticating your application by itself. This "request token" is used in later steps to match all the requests to the same authentication attempt.

The parameter callback is used differently based on how your program is set up, and which authentication process you'd like to use. For applications where directing users to and from another web page is difficult, you can use the special value "oob" to indicate that you would like to use PIN-Based Authentication.

Web-based applications and those that can handle web redirects transparently can instead supply a callback URL for that parameter. When the user completes the sign-in and authentication process, they will be directed to the provided URL with the information necessary to complete the authentication process. Depending on which Step 2 URL you use and whether you've enabled it for your app, this is called "Sign In With Twitter" or "3-Legged Authorization".

With this Request Token, you can assemble an Authorize or Authenticate URL that will allow the user to log in with Twitter and allow your app access to their account. See the Authentication Overview for more details, but the short version is that you want to use Authenticate for "Sign In With Twitter" functionality, and Authorize if not.

Examples

let con_token = egg_mode::KeyPair::new("consumer key", "consumer token");
// for PIN-Based Auth
let req_token = egg_mode::request_token(&con_token, "oob").unwrap();
// for Sign In With Twitter/3-Legged Auth
let req_token = egg_mode::request_token(&con_token, "https://myapp.io/auth").unwrap();