Twitterizer 2 Documentation
OAuthUtility Class
NamespacesTwitterizerOAuthUtility
A utility for handling authorization and request signatures for the OAuth protocol.
Declaration Syntax
C#Visual Basic
public static class OAuthUtility
Public NotInheritable Class OAuthUtility
Members
All MembersMethods



IconMemberDescription
AddOAuthEchoHeader(WebRequest, OAuthTokens)
Adds the OAuth Echo header to the supplied web request.

BuildAuthorizationUri(String)
Builds the authorization URI.

BuildAuthorizationUri(String, Boolean)
Builds the authorization URI.

GetAccessToken(String, String, String, String)
Gets the access token.

GetAccessToken(String, String, String, String, WebProxy)
Gets the access token.

GetAccessTokenDuringCallback(String, String)
Gets the access token during callback.

GetRequestToken(String, String, String)
Gets the request token.

GetRequestToken(String, String, String, WebProxy)
Gets a new OAuth request token from the twitter api.

Remarks

Before you begin, you will need to register your application with Twitter.

To authenticate a user, there are 3 steps you will take:
1) Obtain a Request Token
2) Authentication
3) Obtain an Access Token

Examples
First, you must obtain a request token from the API.
CopyC#
string consumerKey = "XXX";
string consumerSecret = "XXX";

// Obtain a request token
OAuthTokenResponse requestToken = OAuthUtility.GetRequestToken(consumerKey, consumerSecret);

// Direct or instruct the user to the following address:
Uri authorizationUri = OAuthUtility.BuildAuthorizationUri(requestToken.Token);
CopyVB.NET
Dim consumerKey As String = "XXX"
Dim consumerSecret As String = "XXX"

'-- Obtain a request token
Dim requestToken As OAuthTokenResponse = OAuthUtility.GetRequestToken(consumerKey, consumerSecret)

'-- Direct or instruct the user to the following address:
Dim authorizationUri As Uri = OAuthUtility.BuildAuthorizationUri(requestToken.Token)
After the user has returned, you must obtain or reuse the request token and obtain the verifier value. For web applications, both values will be provided on the querystring to the callback url as oauth_token and oauth_verifier, respectively. For desktop and mobile applications, the verifier will be a numeric PIN supplied to the user.
CopyC#
string consumerKey = "XXX";
string consumerSecret = "XXX";
string requestToken = "XXX";
string verifier = "XXX";

// Obtain the access token for this user.
OAuthTokenResponse accessToken = OAuthUtility.GetAccessToken(consumerKey, consumerSecret, requestToken, verifier);

// TODO: Save the access token to a database, session, xml file, or whereever my user data is stored.
CopyVB.NET
Dim consumerKey As String = "XXX"
Dim consumerSecret As String = "XXX"
Dim requestToken As String = "XXX"
Dim verifier As String = "XXX"

'-- Obtain the access token for this user.
Dim accessToken As OAuthTokenResponse = OAuthUtility.GetAccessToken(consumerKey, consumerSecret, requestToken, verifier)

'-- TODO: Save the access token to a database, session, xml file, or whereever my user data is stored.
Inheritance Hierarchy
Object
OAuthUtility
See Also

Assembly: Twitterizer2 (Module: Twitterizer2) Version: 2.3.2.40349 (2.3.2.0)