-
Notifications
You must be signed in to change notification settings - Fork 221
Authentication
linvi edited this page May 11, 2015
·
37 revisions
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.
The PIN based authentication process is quite simple.
- Request Twitter to provide a unique URL that enables a user to authenticate and retrieve a captcha.
- Ask the user to go to this URL.
- Twitter will ask the user to authenticate and accept the permissions requested by your Twitter application.
- If the user accepts, Twitter generates a PIN Code and give it to the user.
- 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);
// Credentials Being Null // Localhost