New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for LinkedIn #29
Comments
Hi. When are you able to release your v.1.0 of Skybrud with implementation of linkedin authentification support? |
LinkedIn is currently not an area of focus, since I'm working on improving the implementation for the services already supported instead. I don't really have a time frame for when But as I wrote in my previous comment, I do have some unfinished code for LinkedIn. I will try to find some time to wrap this a bit, and push the code to GitHub ;) |
@makdff I have now added a new project to the solution called Anyways, this little snippet might help you out with then authentication using OAuth 2.0: @using Skybrud.Social.LinkedIn.OAuth2
@model MvcApplication1.Models.TestPage
@{
ViewBag.Title = "Index";
}
@{
// Handle input
string action = Request.QueryString["do"];
string code = Request.QueryString["code"];
string state = Request.QueryString["state"];
// Initialize the OAuth client
LinkedInOAuthClient oauth = new LinkedInOAuthClient {
ApiKey = "",
ApiSecret = "",
RedirectUri = Model.BaseUrl
};
if (action == "login") {
// Redirect the user to the authentication page at LinkedIn.com
Response.Redirect(oauth.GetAuthorizationUrl("bacon", "r_basicprofile"));
} else if (!String.IsNullOrWhiteSpace(code)) {
LinkedInAccessTokenResponse token = oauth.GetAccessTokenFromAuthCode(code);
oauth.AccessToken = token.AccessToken;
DateTime expiresAt = DateTime.Now.AddSeconds(token.ExpiresIn.TotalSeconds);
<table>
<tr>
<td style="font-size: 10px; font-weight: bold; text-transform: uppercase; padding-right: 25px;">Expires in</td>
<td style="font-size: 12px;">
@token.ExpiresIn.TotalSeconds
(~@token.ExpiresIn.TotalDays days • @expiresAt.ToString("r"))
</td>
</tr>
<tr>
<td style="font-size: 10px; font-weight: bold; text-transform: uppercase; padding-right: 25px;">Access Token</td>
<td style="font-size: 12px;">
@token.AccessToken
</td>
</tr>
</table>
<br />
<a href="@Model.BaseUrl?do=login" class="button">Login again</a>
} else if (Request.QueryString["error"] != null) {
<p><b>@Request.QueryString["error"]</b><br />@Request.QueryString["error_description"]</p>
<a href="@Model.BaseUrl?do=login" class="button">Login with LinkedIn</a>
} else {
<a href="@Model.BaseUrl?do=login" class="button">Login with LinkedIn</a>
}
} |
@abjerner Great thanks :) |
I haven't really updated any of the code, but the LinkedIn implementation now has it's own repository, so you can follow the progress here: https://github.com/abjerner/Skybrud.Social.LinkedIn Eventually the LinkedIn project will also be released as it's own NuGet package, although I don't really have a time frame for this. |
I have some code lying around for this, that I need to finish and clean up a bit. This is probably something that will be added after the release of
v1.0
.The text was updated successfully, but these errors were encountered: