LinkedIn Provider - Added headline, summary, positions and industry (#158)
This commit is contained in:
committed by
Tommy Parnell
parent
d47a6033f8
commit
e919934222
@@ -123,6 +123,22 @@ namespace Owin.Security.Providers.LinkedIn
|
|||||||
context.Identity.AddClaim(new Claim(ClaimTypes.Name, context.Name, XmlSchemaString, Options.AuthenticationType));
|
context.Identity.AddClaim(new Claim(ClaimTypes.Name, context.Name, XmlSchemaString, Options.AuthenticationType));
|
||||||
context.Identity.AddClaim(new Claim("urn:linkedin:name", context.Name, XmlSchemaString, Options.AuthenticationType));
|
context.Identity.AddClaim(new Claim("urn:linkedin:name", context.Name, XmlSchemaString, Options.AuthenticationType));
|
||||||
}
|
}
|
||||||
|
if (!string.IsNullOrEmpty(context.Industry))
|
||||||
|
{
|
||||||
|
context.Identity.AddClaim(new Claim("urn:linkedin:industry", context.Industry, XmlSchemaString, Options.AuthenticationType));
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(context.Positions))
|
||||||
|
{
|
||||||
|
context.Identity.AddClaim(new Claim("urn:linkedin:positions", context.Positions, XmlSchemaString, Options.AuthenticationType));
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(context.Summary))
|
||||||
|
{
|
||||||
|
context.Identity.AddClaim(new Claim("urn:linkedin:summary", context.Summary, XmlSchemaString, Options.AuthenticationType));
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(context.Headline))
|
||||||
|
{
|
||||||
|
context.Identity.AddClaim(new Claim("urn:linkedin:headline", context.Headline, XmlSchemaString, Options.AuthenticationType));
|
||||||
|
}
|
||||||
if (!string.IsNullOrEmpty(context.Link))
|
if (!string.IsNullOrEmpty(context.Link))
|
||||||
{
|
{
|
||||||
context.Identity.AddClaim(new Claim("urn:linkedin:url", context.Link, XmlSchemaString, Options.AuthenticationType));
|
context.Identity.AddClaim(new Claim("urn:linkedin:url", context.Link, XmlSchemaString, Options.AuthenticationType));
|
||||||
|
|||||||
@@ -119,7 +119,11 @@ namespace Owin.Security.Providers.LinkedIn
|
|||||||
"formatted-name",
|
"formatted-name",
|
||||||
"email-address",
|
"email-address",
|
||||||
"public-profile-url",
|
"public-profile-url",
|
||||||
"picture-url"
|
"picture-url",
|
||||||
|
"industry",
|
||||||
|
"headline",
|
||||||
|
"summary",
|
||||||
|
"positions"
|
||||||
};
|
};
|
||||||
BackchannelTimeout = TimeSpan.FromSeconds(60);
|
BackchannelTimeout = TimeSpan.FromSeconds(60);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using Microsoft.Owin;
|
|||||||
using Microsoft.Owin.Security;
|
using Microsoft.Owin.Security;
|
||||||
using Microsoft.Owin.Security.Provider;
|
using Microsoft.Owin.Security.Provider;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Owin.Security.Providers.LinkedIn
|
namespace Owin.Security.Providers.LinkedIn
|
||||||
{
|
{
|
||||||
@@ -41,6 +42,10 @@ namespace Owin.Security.Providers.LinkedIn
|
|||||||
Link = TryGetValue(user, "publicProfileUrl");
|
Link = TryGetValue(user, "publicProfileUrl");
|
||||||
UserName = TryGetValue(user, "formattedName").Replace(" ", "");
|
UserName = TryGetValue(user, "formattedName").Replace(" ", "");
|
||||||
Email = TryGetValue(user, "emailAddress");
|
Email = TryGetValue(user, "emailAddress");
|
||||||
|
Industry = TryGetValue(user, "industry");
|
||||||
|
Summary = TryGetValue(user, "summary");
|
||||||
|
Headline = TryGetValue(user, "headline");
|
||||||
|
Positions = TryGetValueAndSerialize(user, "positions");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -87,6 +92,28 @@ namespace Owin.Security.Providers.LinkedIn
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string FamilyName { get; private set; }
|
public string FamilyName { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describes the users membership profile
|
||||||
|
/// </summary>
|
||||||
|
public string Summary { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Industry the member belongs to
|
||||||
|
/// https://developer.linkedin.com/docs/reference/industry-codes
|
||||||
|
/// </summary>
|
||||||
|
public string Industry { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The members headline
|
||||||
|
/// </summary>
|
||||||
|
public string Headline { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Member's current positions
|
||||||
|
/// https://developer.linkedin.com/docs/fields/positions
|
||||||
|
/// </summary>
|
||||||
|
public string Positions { get; set; }
|
||||||
|
|
||||||
public string Link { get; private set; }
|
public string Link { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -109,5 +136,11 @@ namespace Owin.Security.Providers.LinkedIn
|
|||||||
JToken value;
|
JToken value;
|
||||||
return user.TryGetValue(propertyName, out value) ? value.ToString() : null;
|
return user.TryGetValue(propertyName, out value) ? value.ToString() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string TryGetValueAndSerialize(JObject user, string propertyName)
|
||||||
|
{
|
||||||
|
JToken value;
|
||||||
|
return user.TryGetValue(propertyName, out value) ? JsonConvert.SerializeObject(value) : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user