Skip to content

Authentication

linvi edited this page May 11, 2015 · 37 revisions

Overview

Twitter allows developers to authenticate users against their application credentials. The API gives access to 2 different mechanisms that we will name URL redirect authentication and PIN based authentication.

URL redirection is better suited for Web Application whilst PIN Based authentication is better suited for Desktop application.

PIN Based Authentication

The PIN based authentication process is quite simple.

  1. Request Twitter to provide a unique URL that enables a user to authenticate and retrieve a captcha.
  2. Ask the user to go to this URL.
  3. Twitter will ask the user to authenticate and accept the permissions requested by your Twitter application.
  4. If the user accepts, Twitter generates a PIN Code and give it to the user.
  5. With this code, Twitter can now issue a new OAuth Token available from a WebRequest.

Now let's see how Tweetinvi simplifies this process.

// Store the application only credentials into a variable
var applicationCredentials = CredentialsCreator.GenerateApplicationCredentials(consumerKey, consumerSecret);

// Get the URL that the user needs to visit to accept your application
var url = CredentialsCreator.GetAuthorizationURL(applicationCredentials);

// Implement your own method to request the PIN Code from the User
var pinCode = RequestThePinCodeToTheUser();

// Let Tweetinvi generates the credentials based on the given PIN Code
var userCredentials = CredentialsCreator.GetCredentialsFromVerifierCode(pinCode, applicationCredentials);

Web Application Considerations

// Credentials Being Null // Localhost

Clone this wiki locally