summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.AspNet/Clients/OAuth/LinkedInClient.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.AspNet/Clients/OAuth/LinkedInClient.cs')
-rw-r--r--src/DotNetOpenAuth.AspNet/Clients/OAuth/LinkedInClient.cs70
1 files changed, 45 insertions, 25 deletions
diff --git a/src/DotNetOpenAuth.AspNet/Clients/OAuth/LinkedInClient.cs b/src/DotNetOpenAuth.AspNet/Clients/OAuth/LinkedInClient.cs
index 8f49c80..68cf135 100644
--- a/src/DotNetOpenAuth.AspNet/Clients/OAuth/LinkedInClient.cs
+++ b/src/DotNetOpenAuth.AspNet/Clients/OAuth/LinkedInClient.cs
@@ -7,6 +7,7 @@
namespace DotNetOpenAuth.AspNet.Clients {
using System;
using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Net;
using System.Xml.Linq;
@@ -19,48 +20,69 @@ namespace DotNetOpenAuth.AspNet.Clients {
/// Represents LinkedIn authentication client.
/// </summary>
public sealed class LinkedInClient : OAuthClient {
+ #region Constants and Fields
+
/// <summary>
/// Describes the OAuth service provider endpoints for LinkedIn.
/// </summary>
public static readonly ServiceProviderDescription LinkedInServiceDescription = new ServiceProviderDescription {
- RequestTokenEndpoint = new MessageReceivingEndpoint("https://api.linkedin.com/uas/oauth/requestToken", HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
- UserAuthorizationEndpoint = new MessageReceivingEndpoint("https://www.linkedin.com/uas/oauth/authenticate", HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
- AccessTokenEndpoint = new MessageReceivingEndpoint("https://api.linkedin.com/uas/oauth/accessToken", HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
- TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { new HmacSha1SigningBindingElement() },
+ RequestTokenEndpoint =
+ new MessageReceivingEndpoint(
+ "https://api.linkedin.com/uas/oauth/requestToken",
+ HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
+ UserAuthorizationEndpoint =
+ new MessageReceivingEndpoint(
+ "https://www.linkedin.com/uas/oauth/authenticate",
+ HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
+ AccessTokenEndpoint =
+ new MessageReceivingEndpoint(
+ "https://api.linkedin.com/uas/oauth/accessToken",
+ HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest),
+ TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { new HmacSha1SigningBindingElement() },
};
+ #endregion
+
+ #region Constructors and Destructors
+
/// <summary>
/// Initializes a new instance of the <see cref="LinkedInClient"/> class.
/// </summary>
- /// <param name="consumerKey">The LinkedIn app's consumer key.</param>
- /// <param name="consumerSecret">The LinkedIn app's consumer secret.</param>
- [System.Diagnostics.CodeAnalysis.SuppressMessage(
- "Microsoft.Reliability",
- "CA2000:Dispose objects before losing scope",
+ /// <param name="consumerKey">
+ /// The LinkedIn app's consumer key.
+ /// </param>
+ /// <param name="consumerSecret">
+ /// The LinkedIn app's consumer secret.
+ /// </param>
+ [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope",
Justification = "We can't dispose the object because we still need it through the app lifetime.")]
- public LinkedInClient(string consumerKey, string consumerSecret) :
- base("linkedIn", LinkedInServiceDescription, consumerKey, consumerSecret) {
- }
+ public LinkedInClient(string consumerKey, string consumerSecret)
+ : base("linkedIn", LinkedInServiceDescription, consumerKey, consumerSecret) {}
+
+ #endregion
+
+ #region Methods
/// <summary>
/// Check if authentication succeeded after user is redirected back from the service provider.
/// </summary>
- /// <param name="response">The response token returned from service provider</param>
+ /// <param name="response">
+ /// The response token returned from service provider
+ /// </param>
/// <returns>
- /// Authentication result.
+ /// Authentication result.
/// </returns>
- [System.Diagnostics.CodeAnalysis.SuppressMessage(
- "Microsoft.Design",
- "CA1031:DoNotCatchGeneralExceptionTypes",
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
Justification = "We don't care if the request fails.")]
protected override AuthenticationResult VerifyAuthenticationCore(AuthorizedTokenResponse response) {
// See here for Field Selectors API http://developer.linkedin.com/docs/DOC-1014
- const string profileRequestUrl = "http://api.linkedin.com/v1/people/~:(id,first-name,last-name,headline,industry,summary)";
+ const string profileRequestUrl =
+ "http://api.linkedin.com/v1/people/~:(id,first-name,last-name,headline,industry,summary)";
string accessToken = response.AccessToken;
var profileEndpoint = new MessageReceivingEndpoint(profileRequestUrl, HttpDeliveryMethods.GetRequest);
- HttpWebRequest request = WebWorker.PrepareAuthorizedRequest(profileEndpoint, accessToken);
+ HttpWebRequest request = this.WebWorker.PrepareAuthorizedRequest(profileEndpoint, accessToken);
try {
using (WebResponse profileResponse = request.GetResponse()) {
@@ -79,16 +101,14 @@ namespace DotNetOpenAuth.AspNet.Clients {
extraData.AddDataIfNotEmpty(document, "industry");
return new AuthenticationResult(
- isSuccessful: true,
- provider: ProviderName,
- providerUserId: userId,
- userName: userName,
- extraData: extraData);
+ isSuccessful: true, provider: this.ProviderName, providerUserId: userId, userName: userName, extraData: extraData);
}
}
} catch (Exception exception) {
return new AuthenticationResult(exception);
}
}
+
+ #endregion
}
-} \ No newline at end of file
+}