If you want to user EasyOAuth Library for Web Application, please:

1. Register your application at OAuth Service Provider and obtain consumer key and consumer secret.

2. Download the EasyOAuth Library for Web Application binary code, or download the source codes and build them.

3. Add references for EasyOAuth Library DLLs to your Web application project.

4. Modify the Web.config, add the following configuration section declaration:

<configSections>
  <section name="oauth.configuration" type="OAuth.Web.OAuthWebConfigurationSection, OAuth.Web"/>
</configSections>


5. Modify the Web.config, add the following configuration:

<oauth.configuration defaultPersistProvider="DB" verifyHandler="OAuthVerifyHandler.do" userAcceptedHandler="Result.aspx" userDeniedHandler="Result.aspx">
  <providers>
    <add provider="GoogleAccount" assembly="OAuth.Web" type="OAuth.Web.GoogleOAuthProvider" 
          consumerKey="" consumerSecret="" scope="https://www.google.com/base/feeds/ http://gdata.youtube.com/feeds/api/videos/" 
          consentUrl="https://www.google.com/accounts/OAuthAuthorizeToken" 
          requestTokenUrl="https://www.google.com/accounts/OAuthGetRequestToken" 
          requestAccessTokenUrl="https://www.google.com/accounts/OAuthGetAccessToken" 
          callback="http://[your_url]/OAuthVerifyHandler.do"/>
    <add provider="Yahoo" assembly="OAuth.Web" type="OAuth.Web.YahooOAuthProvider" 
          consumerKey="" consumerSecret="" scope="" 
          consentUrl="https://api.login.yahoo.com/oauth/v2/request_auth" 
          requestTokenUrl="https://api.login.yahoo.com/oauth/v2/get_request_token" 
          requestAccessTokenUrl="https://api.login.yahoo.com/oauth/v2/get_token" 
          callback="http://[your_url]/OAuthVerifyHandler.do"/>
    <add provider="Twitter" assembly="OAuth.Web" type="OAuth.Web.TwitterOAuthProvider" 
          consumerKey="" consumerSecret="" scope="" 
          consentUrl="http://api.twitter.com/oauth/authorize" 
          requestTokenUrl="https://api.twitter.com/oauth/request_token" 
          requestAccessTokenUrl="https://api.twitter.com/oauth/access_token" 
          callback="http://[your_url]/OAuthVerifyHandler.do"/>
    <add provider="Facebook" assembly="OAuth.Web" type="OAuth.Web.FacebookOAuthProvider" 
          consumerKey="" consumerSecret="" scope="publish_stream,read_stream,email,offline_access" 
          consentUrl="https://www.facebook.com/dialog/oauth?client_id={0}&amp;redirect_uri={1}&amp;scope={2}" 
          callback="http://[your_url]/OAuthVerifyHandler.do" 
          requestTokenUrl="" 
          requestAccessTokenUrl="https://graph.facebook.com/oauth/access_token?client_id={0}&amp;redirect_uri={1}&amp;client_secret={2}&amp;code={3}"/>
  </providers>
  <persists>
    <add name="DB" provider="OAuth.PersistDBProvider" connectionString=""/>
    <add name="XML" provider="OAuth.PersistXmlProvider" connectionString=""/>
  </persists>
</oauth.configuration>


Field Descriptions:
  • verifyHandler: The handler handling callback process from OAuth Service Provider.
  • userAcceptedHandler: The handler will be called when user accepted permission requested by application.
  • userDeniedHandler: The handler will be called when user denied permission requested by application.
  • consumerKey: The application key string assigned by OAuth Service Provider for your application.
  • consumerSecret: The application secret string assigned by OAuth Service Provider for your application.
  • scope: Scope definitions your application want to user to authorize, please see the documentation of OAuth Service Provider for details.
  • consentUrl: User authorization process URL provided by OAuth Service Provider, your must change it if service provider changes this URL.
  • requestTokenUrl: The URL for Application want to request an request token, provided by OAuth Service Provider, your must change it if service provider changes this URL.
  • requestAccessTokenUrl: The URL for Application want to obtain an access token, provided by OAuth Service Provider, your must change it if service provider changes this URL.

6. Add OAuthContext call at login page, and create user accepted processing page and user denied processing page to your application.

For more details, please refer the OAuth.Web.Client sample application included at EasyOAuth Library for Web Application's source code.

Last edited Apr 29, 2011 at 9:51 AM by regionbbs, version 4

Comments

No comments yet.