I am working on the development of an application that interrogates several social media providers. However the resources made available by these service providers ( such as Twitter, Facebook,…) are protected by the OAuth protocol. The OAuth protocol enables websites or applications (Consumers) to use Protected Resources from a web service (Service Provider) via an API, without requiring Users to disclose their Service Provider credentials to the Consumers. More generally, OAuth creates a freely-implementable and generic method for API authentication.
An example use case is allowing a picture sharing service (share.example.com), to use photos stored on another service ( hosted.pictures.net) provider without requiring Users to provide their hosted.pictures.net credentials to share.example.com
In a next post I will give you an overview of my implementation of the OAuth protocol in .NET. However before this has any sense you need to understand the OAuth authentication protocol
The OAuth protocol works as follows

Step 0
The consumer needs to register it’s application by the service provider. The service provider will provide you in reply to your request with the consumer key ( unique identifier of your application for the service provider ) and the consumer secret. The service provider also gives you a list of it’s end point URL’s. This information is exchanged between the consumer application’s owner and the service provider. For example for Twitter can you request this information at https://dev.twitter.com/apps
Step 1
In the first step of the authentication protocol, the consumer asks the service provider to issue a request token. The request token’s sole purpose is to receive User approval and can only be used to obtain an Access Token.To obtain a request token, the consumer sends an HTTP request to the service provider’s request token URL ( for example at twitter https://api.twitter.com/oauth/request_token ) with the following parameters
- oauth_consumer_key: the consumer key obtained in step 0 from the service provider
- oauth_signature_method: The signature method of the Consumer used to sign the request
- oauth_signature: The request is signed with the oauth_signature. This signature exists out of the signature base string which is encrypted by the consumer_secret. The base string is a normalized string that consists out of the concatenation of
HTTP method
service provider request URL
oauth_consumer_key
oauth_nonce
oauth_signature_method
oauth_timestamp
oauth_token
oauth_version
for example GET&http%3A%2F%2Fhosted.pictures.net%2Fphotos&%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0
- oauth_timestamp: number of seconds since January 1, 1970 00:00:00 GMT. Timestamp value MUST be a positive integer and MUST be equal or greater than the timestamp used in previous requests
- oauth_nonce: unique value created by the consumer for all requests with the same timestamp. A nonce is a random string, uniquely generated for each request. The nonce allows the service provider to verify that a request has never been made before and heps prevent replay attacks
- oauth_version: most cases oauth_version 1.0
- oauth_callback: An absolute URL to which the Service provider will redirect the User back when the Obtaining user authorization step is completed
The service provider responds to this request with a request token and a request token secret
Step 2
In order for the consumer to be able to exchange the request token for an access token, the consumer must obtain approval from the user by directing the User to the Service Provider. The consumer constructs an HTTP GET request to the Service Provider’s User Authorization URL ( for twitter for example https://api.twitter.com/oauth/authorize ) with the following parameter:
oauth_token: the reques token obtained from the previous step
Once the user authenticates with the service provider and grants permission for consumer acces, the service provides directs the User back to the consumer by using the oauth_callback parameter given in step 1 to the service provider.
Step 3
In step 3 the consumer exchanges its request token by an access token and token secret. To request an access token the consumer makes an HTTP request to the service provider’s access token URL ( for example for Twitter https://api.twitter.com/oauth/access_token) The request contains the same parameters as the request in Step 1 except the request token is added as a parameter
If this request is succesful, the service provider generates an Access Token and Token Secret and returns them in the HTTP response body
Step 4
After succesfully receiving the Access Token and Token Secret, the consumer is able to access the protected resources on behalf of the User. The request MUST be signed per Signing requests, and contains the following parameters
See for more information:
The Oauth 1.0a protocol specification http://oauth.net/core/1.0a/#auth_step1
Beginning guide to OAuth http://hueniverse.com/oauth/guide/intro/