{"id":1164,"date":"2013-10-16T05:33:00","date_gmt":"2013-10-16T05:33:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/webdev\/2013\/10\/16\/get-more-information-from-social-providers-used-in-the-vs-2013-project-templates\/"},"modified":"2022-08-09T03:30:48","modified_gmt":"2022-08-09T10:30:48","slug":"get-more-information-from-social-providers-used-in-the-vs-2013-project-templates","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/get-more-information-from-social-providers-used-in-the-vs-2013-project-templates\/","title":{"rendered":"Get more information from Social providers used in the VS 2013 project templates"},"content":{"rendered":"<p><span style=\"font-size: x-small\"><font size=\"2\">When you create a New ASP.NET Project in VS 2013 and choose Individual Accounts, the template shows how you can login with Social providers such as Microsoft Account, Facebook, Google and Twitter. When you login with these Social Providers such as Facebook, you can request more information about the user such as the User\u2019s picture, friends etc. and if the user allows your app to access this data then you can get this information and provide a rich experience in your site.<\/font><\/span><\/p>\n<p><span style=\"font-size: x-small\"><font size=\"2\">In the following post I am going to show you how you can request more data (or scopes) when a user logs in via Facebook provider. This post assumes that you have enabled Facebook login and are familiar with the basic walkthrough of Facebook Login.&#160; You can visit <\/font><\/span><a href=\"http:\/\/www.asp.net\/mvc\/tutorials\/mvc-5\/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on\"><span style=\"font-size: x-small\"><font size=\"2\">http:\/\/www.asp.net\/mvc\/tutorials\/mvc-5\/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on<\/font><\/span><\/a><span style=\"font-size: x-small\"><font size=\"2\"> to see a basic walkthrough on how to enable Facebook Login in the template.<\/font><\/span><\/p>\n<p><span style=\"font-size: x-small\"><font size=\"2\"><span style=\"background-color: #ffff00\">[<strong>Update<\/strong>]: <\/span>You can find the completed sample at <\/font><a title=\"https:\/\/github.com\/rustd\/FBLogin\" href=\"https:\/\/github.com\/rustd\/FBLogin\"><font size=\"2\">https:\/\/github.com\/rustd\/FBLogin<\/font><\/a><\/span><\/p>\n<h2><strong><span style=\"font-size: x-small\"><font size=\"2\">Following are the steps to get more scopes from Facebook<\/font><\/span><\/strong><\/h2>\n<ul>\n<ul>\n<li><span style=\"font-size: x-small\"><font size=\"2\">In Visual Studio 2013, <strong>create ASP.NET MVC application<\/strong> with Individual Authentication selected.<\/font><\/span> <\/li>\n<li><span style=\"font-size: x-small\"><font size=\"2\"><strong>Enable Facebook Login<\/strong> by getting the keys from Facebook as show in <\/font><\/span><a href=\"http:\/\/www.asp.net\/mvc\/tutorials\/mvc-5\/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on\"><span style=\"font-size: x-small\"><font size=\"2\">http:\/\/www.asp.net\/mvc\/tutorials\/mvc-5\/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on<\/font><\/span><\/a> <\/li>\n<li><font size=\"2\">Modify the following code in StartupAuth.cs to <strong>request more scopes<\/strong> as shown below.<\/font> <\/li>\n<\/ul>\n<\/ul>\n<div id=\"scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:60b105eb-2e28-4960-8b04-b6837ca84f7e\" class=\"wlWriterEditableSmartContent\" style=\"float: none;padding-bottom: 0px;padding-top: 0px;padding-left: 0px;margin: 0px;padding-right: 0px\">\n<div style=\"border: #000080 1px solid;color: #000;font-family: 'Courier New', Courier, Monospace;font-size: 10pt\">\n<div style=\"background: #000080;color: #fff;font-family: Verdana, Tahoma, Arial, sans-serif;font-weight: bold;padding: 2px 5px\">Code Snippet<\/div>\n<div style=\"background: #ddd;max-height: 300px;overflow: auto\">\n<ol start=\"1\" style=\"background: #ffffff;margin: 0 0 0 2.5em;padding: 0 0 0 5px\">\n<li>\u00a0<span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffffff;color:#0000ff\">var<\/span><span style=\"background:#ffffff;color:#000000\"> x = <\/span><span style=\"background:#ffffff;color:#0000ff\">new<\/span><span style=\"background:#ffffff;color:#000000\"> <\/span><span style=\"background:#ffffff;color:#2b91af\">FacebookAuthenticationOptions<\/span><span style=\"background:#ffffff;color:#000000\">();<\/span><\/li>\n<li style=\"background: #f3f3f3\">\u00a0<span style=\"background:#ffffff;color:#000000\">x.Scope.Add(<\/span><span style=\"background:#ffffff;color:#a31515\">&quot;email&quot;<\/span><span style=\"background:#ffffff;color:#000000\">);<\/span><\/li>\n<li>\u00a0<span style=\"background:#ffffff;color:#000000\">x.Scope.Add(<\/span><span style=\"background:#ffffff;color:#a31515\">&quot;friends_about_me&quot;<\/span><span style=\"background:#ffffff;color:#000000\">);<\/span><\/li>\n<li style=\"background: #f3f3f3\">\u00a0<span style=\"background:#ffffff;color:#000000\">x.Scope.Add(<\/span><span style=\"background:#ffffff;color:#a31515\">&quot;friends_photos&quot;<\/span><span style=\"background:#ffffff;color:#000000\">);<\/span><\/li>\n<li>\u00a0<span style=\"background:#ffffff;color:#000000\">x.AppId = <\/span><span style=\"background:#ffffff;color:#a31515\">&quot;YourAppId&quot;<\/span><span style=\"background:#ffffff;color:#000000\">;<\/span><\/li>\n<li style=\"background: #f3f3f3\">\u00a0<span style=\"background:#ffffff;color:#000000\">x.AppSecret = <\/span><span style=\"background:#ffffff;color:#a31515\">&quot;YourAppSecret&quot;<\/span><span style=\"background:#ffffff;color:#000000\">;<\/span><\/li>\n<li>\u00a0<span style=\"background:#ffffff;color:#000000\">x.Provider = <\/span><span style=\"background:#ffffff;color:#0000ff\">new<\/span><span style=\"background:#ffffff;color:#000000\"> <\/span><span style=\"background:#ffffff;color:#2b91af\">FacebookAuthenticationProvider<\/span><span style=\"background:#ffffff;color:#000000\">()<\/span><\/li>\n<li style=\"background: #f3f3f3\"><span style=\"background:#ffffff;color:#000000\">{<\/span><\/li>\n<li>\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\">OnAuthenticated = <\/span><span style=\"background:#ffffff;color:#0000ff\">async<\/span><span style=\"background:#ffffff;color:#000000\"> context =&gt;<\/span><\/li>\n<li style=\"background: #f3f3f3\">\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\">{<\/span><\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffffff;color:#008000\">\/\/Get the access token from FB and store it in the database and<\/span><\/li>\n<li style=\"background: #f3f3f3\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffffff;color:#008000\">\/\/use FacebookC# SDK to get more information about the user<\/span><\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\">context.Identity.AddClaim(<\/span><\/li>\n<li style=\"background: #f3f3f3\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffffff;color:#0000ff\">new<\/span><span style=\"background:#ffffff;color:#000000\"> System.Security.Claims.<\/span><span style=\"background:#ffffff;color:#2b91af\">Claim<\/span><span style=\"background:#ffffff;color:#000000\">(<\/span><span style=\"background:#ffffff;color:#a31515\">&quot;FacebookAccessToken&quot;<\/span><span style=\"background:#ffffff;color:#000000\">,<\/span><\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\">context.AccessToken));<\/span><\/li>\n<li style=\"background: #f3f3f3\">\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\">}<\/span><\/li>\n<li><span style=\"background:#ffffff;color:#000000\">};<\/span><\/li>\n<li style=\"background: #f3f3f3\">\u00a0<span style=\"background:#ffffff;color:#000000\">x.SignInAsAuthenticationType = <\/span><span style=\"background:#ffffff;color:#2b91af\">DefaultAuthenticationTypes<\/span><span style=\"background:#ffffff;color:#000000\">.ExternalCookie;<\/span><\/li>\n<li>\u00a0<span style=\"background:#ffffff;color:#000000\">app.UseFacebookAuthentication(x);<\/span><\/li>\n<\/ol><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<ul>\n<li><span style=\"font-size: x-small\"><font size=\"2\">Line 2-5, we are specifying the scopes.<\/font><\/span> <\/li>\n<li><span style=\"font-size: x-small\"><font size=\"2\">Line 9-15, we are hooking to the OnAuthenticated event for the Facebook OWIN authentication middleware. This method is called each time a user authenticates with Facebook.            <br \/>When the user is authenticated and has granted this app access to this data, all the data is stored in the FacebookContext in the Facebook authentication middleware.             <br \/><\/font><\/span><\/li>\n<li><span style=\"font-size: x-small\"><font size=\"2\">Line 14, also stores the FacebookAccessToken which we get from Facebook and which we will use to get the Users\u2019 friends information&#160;&#160; <\/font><\/span><\/li>\n<\/ul>\n<\/ul>\n<h2><span style=\"font-size: x-small\"><font size=\"2\">Store the FacebookAccessToken and use it in the app to get the list of friends and their pictures<\/font><\/span><\/h2>\n<ul>\n<ul>\n<li>\n<p>Add a link in _LoginPartial.cshtml to display pictures of all friends<\/p>\n<\/li>\n<li>\n<div id=\"scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:8fb5abce-f8ba-4c30-a309-b2f12027efab\" class=\"wlWriterEditableSmartContent\" style=\"float: none;padding-bottom: 0px;padding-top: 0px;padding-left: 0px;margin: 0px;padding-right: 0px\">\n<div style=\"border: #000080 1px solid;color: #000;font-family: 'Courier New', Courier, Monospace;font-size: 10pt\">\n<div style=\"background: #000080;color: #fff;font-family: Verdana, Tahoma, Arial, sans-serif;font-weight: bold;padding: 2px 5px\">Code Snippet<\/div>\n<div style=\"background: #ddd;max-height: 300px;overflow: auto\">\n<ol start=\"1\" style=\"background: #ffffff;margin: 0 0 0 2em;padding: 0 0 0 5px\">\n<li><span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffffff;color:#0000ff\">&lt;<\/span><span style=\"background:#ffffff;color:#800000\">li<\/span><span style=\"background:#ffffff;color:#0000ff\">&gt;&lt;<\/span><span style=\"background:#ffffff;color:#800000\">a<\/span><span style=\"background:#ffffff;color:#000000\"> <\/span><span style=\"background:#ffffff;color:#ff0000\">href<\/span><span style=\"background:#ffffff;color:#0000ff\">=&quot;javascript:document.getElementById(&#039;logoutForm&#039;).submit()&quot;&gt;<\/span><span style=\"background:#ffffff;color:#000000\">Log off<\/span><span style=\"background:#ffffff;color:#0000ff\">&lt;\/<\/span><span style=\"background:#ffffff;color:#800000\">a<\/span><span style=\"background:#ffffff;color:#0000ff\">&gt;&lt;\/<\/span><span style=\"background:#ffffff;color:#800000\">li<\/span><span style=\"background:#ffffff;color:#0000ff\">&gt;<\/span><\/li>\n<li style=\"background: #f3f3f3\"><span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffffff;color:#0000ff\">&lt;<\/span><span style=\"background:#ffffff;color:#800000\">li<\/span><span style=\"background:#ffffff;color:#0000ff\">&gt;<\/span><\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffff00;color:#000000\">@<\/span><span style=\"background:#ffffff;color:#000000\">Html.ActionLink(<\/span><span style=\"background:#ffffff;color:#a31515\">&quot;FacebookInfo&quot;<\/span><span style=\"background:#ffffff;color:#000000\">, <\/span><span style=\"background:#ffffff;color:#a31515\">&quot;FacebookInfo&quot;<\/span><span style=\"background:#ffffff;color:#000000\">, <\/span><span style=\"background:#ffffff;color:#a31515\">&quot;Account&quot;<\/span><span style=\"background:#ffffff;color:#000000\">)<\/span><\/li>\n<li style=\"background: #f3f3f3\">\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\"><\/span><\/li>\n<li><span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffffff;color:#0000ff\">&lt;\/<\/span><span style=\"background:#ffffff;color:#800000\">li<\/span><span style=\"background:#ffffff;color:#0000ff\">&gt;<\/span><\/li>\n<\/ol><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/li>\n<\/ul>\n<li><strong>Get the FacebookAccessToken claim and store it in the UserClaims table using ASP.NET Identity<\/strong>       \n<ul>\n<li>In the following code we get the Claim which was passed from Facebook Middleware to the app <\/li>\n<li><font size=\"2\">StoreFacebookAuthToken gets the claims from the UserIdentity and persists the AccessToken in the database as a User Claim.<\/font> <\/li>\n<li><font size=\"2\"><strong>LinkLoginCallback<\/strong> action is called when the user is logged in and is associating another login provider.<\/font> <font size=\"2\"><\/font><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div id=\"scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9c4eda3e-9690-4814-8005-4e63e7ebb4b7\" class=\"wlWriterSmartContent\" style=\"float: none;padding-bottom: 0px;padding-top: 0px;padding-left: 0px;margin: 0px;padding-right: 0px\">\n<div style=\"font-size: 10pt;border-top: #000080 1px solid;font-family: verdana, tahoma, arial, sans-serif;border-right: #000080 1px solid;background: #000080;border-bottom: #000080 1px solid;font-weight: bold;color: #fff;padding-bottom: 2px;padding-top: 2px;padding-left: 5px;border-left: #000080 1px solid;padding-right: 5px\">Code Snippet<\/div>\n<div>\n<div style=\"overflow: auto;background: #ddd;max-height: 300px\">\n<ol style=\"background: #ffffff;padding-bottom: 0px;padding-top: 0px;padding-left: 5px;margin: 0px 0px 0px 2.5em;padding-right: 0px\">\n<li><span style=\"background: #ffffff;color: #008000\">\/\/<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #008000\">\/\/ GET: \/Account\/LinkLoginCallback<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">public<\/span><span style=\"background: #ffffff;color: #0000ff\">async<\/span><span style=\"background: #ffffff;color: #2b91af\">Task<\/span><span style=\"background: #ffffff;color: #000000\">&lt;<\/span><span style=\"background: #ffffff;color: #2b91af\">ActionResult<\/span><span style=\"background: #ffffff;color: #000000\">&gt; LinkLoginCallback()<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">{<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">var<\/span><span style=\"background: #ffffff;color: #000000\"> loginInfo = <\/span><span style=\"background: #ffffff;color: #0000ff\">await<\/span><span style=\"background: #ffffff;color: #000000\"> AuthenticationManager.GetExternalLoginInfoAsync(XsrfKey, User.Identity.GetUserId());<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">if<\/span><span style=\"background: #ffffff;color: #000000\"> (loginInfo == <\/span><span style=\"background: #ffffff;color: #0000ff\">null<\/span><span style=\"background: #ffffff;color: #000000\">)<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">{<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">return<\/span><span style=\"background: #ffffff;color: #000000\"> RedirectToAction(<\/span><span style=\"background: #ffffff;color: #a31515\">&quot;Manage&quot;<\/span><span style=\"background: #ffffff;color: #000000\">, <\/span><span style=\"background: #ffffff;color: #0000ff\">new<\/span><span style=\"background: #ffffff;color: #000000\"> { Message = <\/span><span style=\"background: #ffffff;color: #2b91af\">ManageMessageId<\/span><span style=\"background: #ffffff;color: #000000\">.Error });<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">}<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">var<\/span><span style=\"background: #ffffff;color: #000000\"> result = <\/span><span style=\"background: #ffffff;color: #0000ff\">await<\/span><span style=\"background: #ffffff;color: #000000\"> UserManager.AddLoginAsync(User.Identity.GetUserId(), loginInfo.Login);<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">if<\/span><span style=\"background: #ffffff;color: #000000\"> (result.Succeeded)<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">{<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">var<\/span><span style=\"background: #ffffff;color: #000000\"> currentUser = <\/span><span style=\"background: #ffffff;color: #0000ff\">await<\/span><span style=\"background: #ffffff;color: #000000\"> UserManager.FindByIdAsync(User.Identity.GetUserId());<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #008000\">\/\/Add the Facebook Claim<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">await<\/span><span style=\"background: #ffffff;color: #000000\"> StoreFacebookAuthToken(currentUser);<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">return<\/span><span style=\"background: #ffffff;color: #000000\"> RedirectToAction(<\/span><span style=\"background: #ffffff;color: #a31515\">&quot;Manage&quot;<\/span><span style=\"background: #ffffff;color: #000000\">);<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">}<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">return<\/span><span style=\"background: #ffffff;color: #000000\"> RedirectToAction(<\/span><span style=\"background: #ffffff;color: #a31515\">&quot;Manage&quot;<\/span><span style=\"background: #ffffff;color: #000000\">, <\/span><span style=\"background: #ffffff;color: #0000ff\">new<\/span><span style=\"background: #ffffff;color: #000000\"> { Message = <\/span><span style=\"background: #ffffff;color: #2b91af\">ManageMessageId<\/span><span style=\"background: #ffffff;color: #000000\">.Error });<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">}<\/span> <\/li>\n<\/ol><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<p> <font size=\"2\"><span style=\"font-size: x-small\"><\/span><\/font>  <\/p>\n<ul>\n<li><strong><font size=\"2\">ExternalLoginConfirmation <\/font><\/strong><font size=\"2\">action is called when you login with the Facebook provider for the first time.<\/font>       \n<ul>\n<li><font size=\"2\">In Line 26, once the User is created we add a new line to add&#160; the FacebookAccessToken as a claim for the user.<\/font> <\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div id=\"scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:476ff03f-8732-49b7-9b03-57acbab0cee6\" class=\"wlWriterSmartContent\" style=\"float: none;padding-bottom: 0px;padding-top: 0px;padding-left: 0px;margin: 0px;padding-right: 0px\">\n<div>\n<div style=\"font-family: verdana, tahoma, arial, sans-serif;background: #000080;font-weight: bold;color: #fff;padding-bottom: 2px;padding-top: 2px;padding-left: 5px;padding-right: 5px\">Code Snippet<\/div>\n<div style=\"overflow: auto;background: #ddd;max-height: 300px\">\n<ol style=\"background: #ffffff;padding-bottom: 0px;padding-top: 0px;padding-left: 5px;margin: 0px 0px 0px 2.5em;padding-right: 0px\">\n<li><span style=\"background: #ffffff;color: #000000\">[<\/span><span style=\"background: #ffffff;color: #2b91af\">HttpPost<\/span><span style=\"background: #ffffff;color: #000000\">]<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">[<\/span><span style=\"background: #ffffff;color: #2b91af\">AllowAnonymous<\/span><span style=\"background: #ffffff;color: #000000\">]<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">[<\/span><span style=\"background: #ffffff;color: #2b91af\">ValidateAntiForgeryToken<\/span><span style=\"background: #ffffff;color: #000000\">]<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">public<\/span><span style=\"background: #ffffff;color: #0000ff\">async<\/span><span style=\"background: #ffffff;color: #2b91af\">Task<\/span><span style=\"background: #ffffff;color: #000000\">&lt;<\/span><span style=\"background: #ffffff;color: #2b91af\">ActionResult<\/span><span style=\"background: #ffffff;color: #000000\">&gt; ExternalLoginConfirmation(<\/span><span style=\"background: #ffffff;color: #2b91af\">ExternalLoginConfirmationViewModel<\/span><span style=\"background: #ffffff;color: #000000\"> model, <\/span><span style=\"background: #ffffff;color: #0000ff\">string<\/span><span style=\"background: #ffffff;color: #000000\"> returnUrl)<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">{<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">if<\/span><span style=\"background: #ffffff;color: #000000\"> (User.Identity.IsAuthenticated)<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">{<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">return<\/span><span style=\"background: #ffffff;color: #000000\"> RedirectToAction(<\/span><span style=\"background: #ffffff;color: #a31515\">&quot;Manage&quot;<\/span><span style=\"background: #ffffff;color: #000000\">);<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">}<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160; <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">if<\/span><span style=\"background: #ffffff;color: #000000\"> (ModelState.IsValid)<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">{<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #008000\">\/\/ Get the information about the user from the external login provider<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">var<\/span><span style=\"background: #ffffff;color: #000000\"> info = <\/span><span style=\"background: #ffffff;color: #0000ff\">await<\/span><span style=\"background: #ffffff;color: #000000\"> AuthenticationManager.GetExternalLoginInfoAsync();<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">if<\/span><span style=\"background: #ffffff;color: #000000\"> (info == <\/span><span style=\"background: #ffffff;color: #0000ff\">null<\/span><span style=\"background: #ffffff;color: #000000\">)<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">{<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">return<\/span><span style=\"background: #ffffff;color: #000000\"> View(<\/span><span style=\"background: #ffffff;color: #a31515\">&quot;ExternalLoginFailure&quot;<\/span><span style=\"background: #ffffff;color: #000000\">);<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">}<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">var<\/span><span style=\"background: #ffffff;color: #000000\"> user = <\/span><span style=\"background: #ffffff;color: #0000ff\">new<\/span><span style=\"background: #ffffff;color: #2b91af\">ApplicationUser<\/span><span style=\"background: #ffffff;color: #000000\">() { UserName = model.Email };<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">var<\/span><span style=\"background: #ffffff;color: #000000\"> result = <\/span><span style=\"background: #ffffff;color: #0000ff\">await<\/span><span style=\"background: #ffffff;color: #000000\"> UserManager.CreateAsync(user);<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">if<\/span><span style=\"background: #ffffff;color: #000000\"> (result.Succeeded)<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">{<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">result = <\/span><span style=\"background: #ffffff;color: #0000ff\">await<\/span><span style=\"background: #ffffff;color: #000000\"> UserManager.AddLoginAsync(user.Id, info.Login);<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">if<\/span><span style=\"background: #ffffff;color: #000000\"> (result.Succeeded)<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">{<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">await<\/span><span style=\"background: #ffffff;color: #000000\"> StoreFacebookAuthToken(user);<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">await<\/span><span style=\"background: #ffffff;color: #000000\"> SignInAsync(user, isPersistent: <\/span><span style=\"background: #ffffff;color: #0000ff\">false<\/span><span style=\"background: #ffffff;color: #000000\">);<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">return<\/span><span style=\"background: #ffffff;color: #000000\"> RedirectToLocal(returnUrl);<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">}<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">}<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">AddErrors(result);<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">}<\/span> <\/li>\n<li>&#160; <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">ViewBag.ReturnUrl = returnUrl;<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">return<\/span><span style=\"background: #ffffff;color: #000000\"> View(model);<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">}<\/span> <\/li>\n<\/ol><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li><font size=\"2\"><strong>ExternalLoginCallback<\/strong> action is called when you associate the User with an external login provider for the first time. <strong><\/strong><\/font>      \n<ul>\n<li><font size=\"2\"><strong>In line 17 we add a new line to add the FacebookAccessToken as a claim for the user.<\/strong> <\/font><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div id=\"scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:532330e6-8071-4039-a803-e80d5749dccd\" class=\"wlWriterSmartContent\" style=\"float: none;padding-bottom: 0px;padding-top: 0px;padding-left: 0px;margin: 0px;padding-right: 0px\">\n<div style=\"font-size: 10pt;border-top: #000080 1px solid;font-family: verdana, tahoma, arial, sans-serif;border-right: #000080 1px solid;background: #000080;border-bottom: #000080 1px solid;font-weight: bold;color: #fff;padding-bottom: 2px;padding-top: 2px;padding-left: 5px;border-left: #000080 1px solid;padding-right: 5px\">Code Snippet<\/div>\n<div>\n<div style=\"overflow: auto;background: #ddd;max-height: 300px\">\n<ol style=\"background: #ffffff;padding-bottom: 0px;padding-top: 0px;padding-left: 5px;margin: 0px 0px 0px 2.5em;padding-right: 0px\">\n<li><span style=\"background: #ffffff;color: #008000\">\/\/<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #008000\">\/\/ GET: \/Account\/ExternalLoginCallback<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">[<\/span><span style=\"background: #ffffff;color: #2b91af\">AllowAnonymous<\/span><span style=\"background: #ffffff;color: #000000\">]<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">public<\/span><span style=\"background: #ffffff;color: #0000ff\">async<\/span><span style=\"background: #ffffff;color: #2b91af\">Task<\/span><span style=\"background: #ffffff;color: #000000\">&lt;<\/span><span style=\"background: #ffffff;color: #2b91af\">ActionResult<\/span><span style=\"background: #ffffff;color: #000000\">&gt; ExternalLoginCallback(<\/span><span style=\"background: #ffffff;color: #0000ff\">string<\/span><span style=\"background: #ffffff;color: #000000\"> returnUrl)<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">{<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">var<\/span><span style=\"background: #ffffff;color: #000000\"> loginInfo = <\/span><span style=\"background: #ffffff;color: #0000ff\">await<\/span><span style=\"background: #ffffff;color: #000000\"> AuthenticationManager.GetExternalLoginInfoAsync();<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">if<\/span><span style=\"background: #ffffff;color: #000000\"> (loginInfo == <\/span><span style=\"background: #ffffff;color: #0000ff\">null<\/span><span style=\"background: #ffffff;color: #000000\">)<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">{<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">return<\/span><span style=\"background: #ffffff;color: #000000\"> RedirectToAction(<\/span><span style=\"background: #ffffff;color: #a31515\">&quot;Login&quot;<\/span><span style=\"background: #ffffff;color: #000000\">);<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">}<\/span> <\/li>\n<li>&#160; <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #008000\">\/\/ Sign in the user with this external login provider if the user already has a login<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">var<\/span><span style=\"background: #ffffff;color: #000000\"> user = <\/span><span style=\"background: #ffffff;color: #0000ff\">await<\/span><span style=\"background: #ffffff;color: #000000\"> UserManager.FindAsync(loginInfo.Login);<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">if<\/span><span style=\"background: #ffffff;color: #000000\"> (user != <\/span><span style=\"background: #ffffff;color: #0000ff\">null<\/span><span style=\"background: #ffffff;color: #000000\">)<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">{<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #008000\">\/\/Save the FacebookToken in the database if not already there<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">await<\/span><span style=\"background: #ffffff;color: #000000\"> StoreFacebookAuthToken(user);<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">await<\/span><span style=\"background: #ffffff;color: #000000\"> SignInAsync(user, isPersistent: <\/span><span style=\"background: #ffffff;color: #0000ff\">false<\/span><span style=\"background: #ffffff;color: #000000\">);<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">return<\/span><span style=\"background: #ffffff;color: #000000\"> RedirectToLocal(returnUrl);<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">}<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">else<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">{<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #008000\">\/\/ If the user does not have an account, then prompt the user to create an account<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">ViewBag.ReturnUrl = returnUrl;<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">ViewBag.LoginProvider = loginInfo.Login.LoginProvider;<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">return<\/span><span style=\"background: #ffffff;color: #000000\"> View(<\/span><span style=\"background: #ffffff;color: #a31515\">&quot;ExternalLoginConfirmation&quot;<\/span><span style=\"background: #ffffff;color: #000000\">, <\/span><span style=\"background: #ffffff;color: #0000ff\">new<\/span><span style=\"background: #ffffff;color: #2b91af\">ExternalLoginConfirmationViewModel<\/span><span style=\"background: #ffffff;color: #000000\"> { Email = loginInfo.Email });<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">}<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">}<\/span> <\/li>\n<\/ol><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<p><font size=\"2\"><span style=\"font-size: x-small\"><strong><\/strong><\/span><\/font><\/p>\n<h2><font size=\"2\"><span style=\"font-size: x-small\"><strong><\/strong><\/span><\/font><\/h2>\n<ul>\n<li>\n<p><font size=\"2\">This stores the FacebookAccessToken as a User Claim in the ASP.NET Identity database<\/font><\/p>\n<\/li>\n<\/ul>\n<\/ul>\n<div id=\"scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f73f72a6-2a62-4984-99eb-ba21becd4a70\" class=\"wlWriterSmartContent\" style=\"float: none;padding-bottom: 0px;padding-top: 0px;padding-left: 0px;margin: 0px;padding-right: 0px\">\n<div>\n<div style=\"font-family: verdana, tahoma, arial, sans-serif;background: #000080;font-weight: bold;color: #fff;padding-bottom: 2px;padding-top: 2px;padding-left: 5px;padding-right: 5px\">Code Snippet<\/div>\n<div style=\"overflow: auto;background: #ddd;max-height: 300px\">\n<ol style=\"background: #ffffff;padding-bottom: 0px;padding-top: 0px;padding-left: 5px;margin: 0px 0px 0px 2.5em;padding-right: 0px\">\n<li><span style=\"background: #ffffff;color: #0000ff\">private<\/span><span style=\"background: #ffffff;color: #0000ff\">async<\/span><span style=\"background: #ffffff;color: #2b91af\">Task<\/span><span style=\"background: #ffffff;color: #000000\"> StoreFacebookAuthToken(<\/span><span style=\"background: #ffffff;color: #2b91af\">ApplicationUser<\/span><span style=\"background: #ffffff;color: #000000\"> user)<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">{<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">var<\/span><span style=\"background: #ffffff;color: #000000\"> claimsIdentity = <\/span><span style=\"background: #ffffff;color: #0000ff\">await<\/span><span style=\"background: #ffffff;color: #000000\"> AuthenticationManager.GetExternalIdentityAsync(<\/span><span style=\"background: #ffffff;color: #2b91af\">DefaultAuthenticationTypes<\/span><span style=\"background: #ffffff;color: #000000\">.ExternalCookie);<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">if<\/span><span style=\"background: #ffffff;color: #000000\"> (claimsIdentity != <\/span><span style=\"background: #ffffff;color: #0000ff\">null<\/span><span style=\"background: #ffffff;color: #000000\">)<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">{<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #008000\">\/\/ Retrieve the existing claims for the user and add the FacebookAccessTokenClaim<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">var<\/span><span style=\"background: #ffffff;color: #000000\"> currentClaims = <\/span><span style=\"background: #ffffff;color: #0000ff\">await<\/span><span style=\"background: #ffffff;color: #000000\"> UserManager.GetClaimsAsync(user.Id);<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">var<\/span><span style=\"background: #ffffff;color: #000000\"> facebookAccessToken = claimsIdentity.FindAll(<\/span><span style=\"background: #ffffff;color: #a31515\">&quot;FacebookAccessToken&quot;<\/span><span style=\"background: #ffffff;color: #000000\">).First();<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">if<\/span><span style=\"background: #ffffff;color: #000000\"> (currentClaims.Count() &lt;=0 )<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">{<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">await<\/span><span style=\"background: #ffffff;color: #000000\"> UserManager.AddClaimAsync(user.Id, facebookAccessToken);<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">}<\/span> <\/li>\n<\/ol><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li><span style=\"font-size: x-small\"><font size=\"2\"><strong>Install the Facebook C#SDK NuGet package<\/strong>. <\/font><\/span><a href=\"http:\/\/nuget.org\/packages\/Facebook\"><span style=\"font-size: x-small\"><font size=\"2\">http:\/\/nuget.org\/packages\/Facebook<\/font><\/span><\/a>       \n<ul>\n<li>Add the following code in AccountViewModel<font size=\"2\"><span style=\"font-size: x-small\"><strong><\/strong><\/span><\/font> <\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div id=\"scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6c79ec15-e698-4f90-983d-7fa18a0dd804\" class=\"wlWriterEditableSmartContent\" style=\"float: none;padding-bottom: 0px;padding-top: 0px;padding-left: 0px;margin: 0px;padding-right: 0px\">\n<div style=\"border: #000080 1px solid;color: #000;font-family: 'Courier New', Courier, Monospace;font-size: 10pt\">\n<div style=\"background: #000080;color: #fff;font-family: Verdana, Tahoma, Arial, sans-serif;font-weight: bold;padding: 2px 5px\">Code Snippet<\/div>\n<div style=\"background: #ddd;max-height: 300px;overflow: auto\">\n<ol start=\"1\" style=\"background: #ffffff;margin: 0 0 0 2em;padding: 0 0 0 5px\">\n<li>\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffffff;color:#0000ff\">public<\/span><span style=\"background:#ffffff;color:#000000\"> <\/span><span style=\"background:#ffffff;color:#0000ff\">class<\/span><span style=\"background:#ffffff;color:#000000\"> <\/span><span style=\"background:#ffffff;color:#2b91af\">FacebookViewModel<\/span><\/li>\n<li style=\"background: #f3f3f3\">\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\">{<\/span><\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\">[<\/span><span style=\"background:#ffffff;color:#2b91af\">Required<\/span><span style=\"background:#ffffff;color:#000000\">]<\/span><\/li>\n<li style=\"background: #f3f3f3\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\">[<\/span><span style=\"background:#ffffff;color:#2b91af\">Display<\/span><span style=\"background:#ffffff;color:#000000\">(Name = <\/span><span style=\"background:#ffffff;color:#a31515\">&quot;Friend&#039;s name&quot;<\/span><span style=\"background:#ffffff;color:#000000\">)]<\/span><\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffffff;color:#0000ff\">public<\/span><span style=\"background:#ffffff;color:#000000\"> <\/span><span style=\"background:#ffffff;color:#0000ff\">string<\/span><span style=\"background:#ffffff;color:#000000\"> Name { <\/span><span style=\"background:#ffffff;color:#0000ff\">get<\/span><span style=\"background:#ffffff;color:#000000\">; <\/span><span style=\"background:#ffffff;color:#0000ff\">set<\/span><span style=\"background:#ffffff;color:#000000\">; }<\/span><\/li>\n<li style=\"background: #f3f3f3\"><span style=\"background:#ffffff;color:#000000\"><\/span><\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffffff;color:#0000ff\">public<\/span><span style=\"background:#ffffff;color:#000000\"> <\/span><span style=\"background:#ffffff;color:#0000ff\">string<\/span><span style=\"background:#ffffff;color:#000000\"> ImageURL { <\/span><span style=\"background:#ffffff;color:#0000ff\">get<\/span><span style=\"background:#ffffff;color:#000000\">; <\/span><span style=\"background:#ffffff;color:#0000ff\">set<\/span><span style=\"background:#ffffff;color:#000000\">; }<\/span><\/li>\n<li style=\"background: #f3f3f3\">\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\">}<\/span><\/li>\n<\/ol><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li>Add the following Action in the Account Controller. This action gets the FacebookAccessToken and makes a call to Facebook using Facebook C# SDK to get the list of friends and their pictures. <\/li>\n<\/ul>\n<div id=\"scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:68ffb91d-79ad-40aa-826e-22de4a22d189\" class=\"wlWriterSmartContent\" style=\"float: none;padding-bottom: 0px;padding-top: 0px;padding-left: 0px;margin: 0px;padding-right: 0px\">\n<div style=\"font-size: 10pt;border-top: #000080 1px solid;font-family: verdana, tahoma, arial, sans-serif;border-right: #000080 1px solid;background: #000080;border-bottom: #000080 1px solid;font-weight: bold;color: #fff;padding-bottom: 2px;padding-top: 2px;padding-left: 5px;border-left: #000080 1px solid;padding-right: 5px\">Code Snippet<\/div>\n<div>\n<div style=\"overflow: auto;background: #ddd;max-height: 300px\">\n<ol style=\"background: #ffffff;padding-bottom: 0px;padding-top: 0px;padding-left: 5px;margin: 0px 0px 0px 2.5em;padding-right: 0px\">\n<li><span style=\"background: #ffffff;color: #008000\">\/\/GET: Account\/FacebookInfo<\/span> <\/li>\n<li style=\"background: #f3f3f3\"><span style=\"background: #ffffff;color: #000000\">[<\/span><span style=\"background: #ffffff;color: #2b91af\">Authorize<\/span><span style=\"background: #ffffff;color: #000000\">]<\/span> <\/li>\n<li><span style=\"background: #ffffff;color: #0000ff\">public<\/span><span style=\"background: #ffffff;color: #0000ff\">async<\/span><span style=\"background: #ffffff;color: #2b91af\">Task<\/span><span style=\"background: #ffffff;color: #000000\">&lt;<\/span><span style=\"background: #ffffff;color: #2b91af\">ActionResult<\/span><span style=\"background: #ffffff;color: #000000\">&gt; FacebookInfo()<\/span> <\/li>\n<li style=\"background: #f3f3f3\"><span style=\"background: #ffffff;color: #000000\">{<\/span> <\/li>\n<li>&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">var<\/span><span style=\"background: #ffffff;color: #000000\"> claimsforUser = <\/span><span style=\"background: #ffffff;color: #0000ff\">await<\/span><span style=\"background: #ffffff;color: #000000\"> UserManager.GetClaimsAsync(User.Identity.GetUserId());<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">var<\/span><span style=\"background: #ffffff;color: #000000\"> access_token = claimsforUser.FirstOrDefault(x =&gt; x.Type == <\/span><span style=\"background: #ffffff;color: #a31515\">&quot;FacebookAccessToken&quot;<\/span><span style=\"background: #ffffff;color: #000000\">).Value;<\/span> <\/li>\n<li>&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">var<\/span><span style=\"background: #ffffff;color: #000000\"> fb = <\/span><span style=\"background: #ffffff;color: #0000ff\">new<\/span><span style=\"background: #ffffff;color: #2b91af\">FacebookClient<\/span><span style=\"background: #ffffff;color: #000000\">(access_token);<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">dynamic<\/span><span style=\"background: #ffffff;color: #000000\"> myInfo = fb.Get(<\/span><span style=\"background: #ffffff;color: #a31515\">&quot;\/me\/friends&quot;<\/span><span style=\"background: #ffffff;color: #000000\">);<\/span> <\/li>\n<li>&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">var<\/span><span style=\"background: #ffffff;color: #000000\"> friendsList = <\/span><span style=\"background: #ffffff;color: #0000ff\">new<\/span><span style=\"background: #ffffff;color: #2b91af\">List<\/span><span style=\"background: #ffffff;color: #000000\">&lt;<\/span><span style=\"background: #ffffff;color: #2b91af\">FacebookViewModel<\/span><span style=\"background: #ffffff;color: #000000\">&gt;();<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">foreach<\/span><span style=\"background: #ffffff;color: #000000\"> (<\/span><span style=\"background: #ffffff;color: #0000ff\">dynamic<\/span><span style=\"background: #ffffff;color: #000000\"> friend <\/span><span style=\"background: #ffffff;color: #0000ff\">in<\/span><span style=\"background: #ffffff;color: #000000\"> myInfo.data)<\/span> <\/li>\n<li>&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">{<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">friendsList.Add(<\/span><span style=\"background: #ffffff;color: #0000ff\">new<\/span><span style=\"background: #ffffff;color: #2b91af\">FacebookViewModel<\/span><span style=\"background: #ffffff;color: #000000\">()<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">{<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">Name = friend.name,<\/span> <\/li>\n<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">ImageURL = <\/span><span style=\"background: #ffffff;color: #a31515\">@&quot;https:\/\/graph.facebook.com\/&quot;<\/span><span style=\"background: #ffffff;color: #000000\"> + friend.id + <\/span><span style=\"background: #ffffff;color: #a31515\">&quot;\/picture?type=large&quot;<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">});<\/span> <\/li>\n<li>&#160;&#160;&#160; <span style=\"background: #ffffff;color: #000000\">}<\/span> <\/li>\n<li style=\"background: #f3f3f3\">&#160; <\/li>\n<li>&#160;&#160;&#160; <span style=\"background: #ffffff;color: #0000ff\">return<\/span><span style=\"background: #ffffff;color: #000000\"> View(friendsList);<\/span> <\/li>\n<li style=\"background: #f3f3f3\"><span style=\"background: #ffffff;color: #000000\">}<\/span> <\/li>\n<\/ol><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li>Add a new View FacebookInfo.cshtml under ViewsAccount and add the following markup <\/li>\n<\/ul>\n<div id=\"scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:80dfe31a-deb7-46d1-8aae-c2aff3bb2d9c\" class=\"wlWriterEditableSmartContent\" style=\"float: none;padding-bottom: 0px;padding-top: 0px;padding-left: 0px;margin: 0px;padding-right: 0px\">\n<div style=\"border: #000080 1px solid;color: #000;font-family: 'Courier New', Courier, Monospace;font-size: 10pt\">\n<div style=\"background: #000080;color: #fff;font-family: Verdana, Tahoma, Arial, sans-serif;font-weight: bold;padding: 2px 5px\">Code Snippet<\/div>\n<div style=\"background: #ddd;max-height: 300px;overflow: auto\">\n<ol start=\"1\" style=\"background: #ffffff;margin: 0 0 0 2.5em;padding: 0 0 0 5px\">\n<li><span style=\"background:#ffff00;color:#000000\">@model <\/span><span style=\"background:#ffffff;color:#2b91af\">IList<\/span><span style=\"background:#ffffff;color:#000000\">&lt;FB.Models.<\/span><span style=\"background:#ffffff;color:#2b91af\">FacebookViewModel<\/span><span style=\"background:#ffffff;color:#000000\">&gt;<\/span><\/li>\n<li style=\"background: #f3f3f3\">\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffff00;color:#000000\">@<\/span><span style=\"background:#ffffff;color:#0000ff\">if<\/span><span style=\"background:#ffffff;color:#000000\"> (Model.Count &gt; 0)<\/span><\/li>\n<li>\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\">{<\/span><\/li>\n<li style=\"background: #f3f3f3\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffffff;color:#0000ff\">&lt;<\/span><span style=\"background:#ffffff;color:#800000\">h3<\/span><span style=\"background:#ffffff;color:#0000ff\">&gt;<\/span><span style=\"background:#ffffff;color:#000000\">List of friends<\/span><span style=\"background:#ffffff;color:#0000ff\">&lt;\/<\/span><span style=\"background:#ffffff;color:#800000\">h3<\/span><span style=\"background:#ffffff;color:#0000ff\">&gt;<\/span><\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffffff;color:#0000ff\">&lt;<\/span><span style=\"background:#ffffff;color:#800000\">div<\/span><span style=\"background:#ffffff;color:#000000\"> <\/span><span style=\"background:#ffffff;color:#ff0000\">class<\/span><span style=\"background:#ffffff;color:#0000ff\">=&quot;row&quot;&gt;<\/span><\/li>\n<li style=\"background: #f3f3f3\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffff00;color:#000000\">@<\/span><span style=\"background:#ffffff;color:#0000ff\">foreach<\/span><span style=\"background:#ffffff;color:#000000\"> (<\/span><span style=\"background:#ffffff;color:#0000ff\">var<\/span><span style=\"background:#ffffff;color:#000000\"> friend <\/span><span style=\"background:#ffffff;color:#0000ff\">in<\/span><span style=\"background:#ffffff;color:#000000\"> Model)<\/span><\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\">{<\/span><\/li>\n<li style=\"background: #f3f3f3\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffffff;color:#0000ff\">&lt;<\/span><span style=\"background:#ffffff;color:#800000\">div<\/span><span style=\"background:#ffffff;color:#000000\"> <\/span><span style=\"background:#ffffff;color:#ff0000\">class<\/span><span style=\"background:#ffffff;color:#0000ff\">=&quot;col-md-3&quot;&gt;<\/span><\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffffff;color:#0000ff\">&lt;<\/span><span style=\"background:#ffffff;color:#800000\">a<\/span><span style=\"background:#ffffff;color:#000000\"> <\/span><span style=\"background:#ffffff;color:#ff0000\">href<\/span><span style=\"background:#ffffff;color:#0000ff\">=&quot;#&quot;<\/span><span style=\"background:#ffffff;color:#000000\"> <\/span><span style=\"background:#ffffff;color:#ff0000\">class<\/span><span style=\"background:#ffffff;color:#0000ff\">=&quot;thumbnail&quot;&gt;<\/span><\/li>\n<li style=\"background: #f3f3f3\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffffff;color:#0000ff\">&lt;<\/span><span style=\"background:#ffffff;color:#800000\">img<\/span><span style=\"background:#ffffff;color:#000000\"> <\/span><span style=\"background:#ffffff;color:#ff0000\">src<\/span><span style=\"background:#ffffff;color:#0000ff\">=<\/span><span style=\"background:#ffff00;color:#000000\">@<\/span><span style=\"background:#ffffff;color:#000000\">friend.ImageURL <\/span><span style=\"background:#ffffff;color:#ff0000\">alt<\/span><span style=\"background:#ffffff;color:#0000ff\">=<\/span><span style=\"background:#ffff00;color:#000000\">@<\/span><span style=\"background:#ffffff;color:#000000\">friend.Name <\/span><span style=\"background:#ffffff;color:#0000ff\">\/&gt;<\/span><\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffffff;color:#0000ff\">&lt;\/<\/span><span style=\"background:#ffffff;color:#800000\">a<\/span><span style=\"background:#ffffff;color:#0000ff\">&gt;<\/span><\/li>\n<li style=\"background: #f3f3f3\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffffff;color:#0000ff\">&lt;\/<\/span><span style=\"background:#ffffff;color:#800000\">div<\/span><span style=\"background:#ffffff;color:#0000ff\">&gt;<\/span><\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\">}<\/span><\/li>\n<li style=\"background: #f3f3f3\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\"><\/span><span style=\"background:#ffffff;color:#0000ff\">&lt;\/<\/span><span style=\"background:#ffffff;color:#800000\">div<\/span><span style=\"background:#ffffff;color:#0000ff\">&gt;<\/span><\/li>\n<li>\u00a0\u00a0<span style=\"background:#ffffff;color:#000000\">}<\/span><\/li>\n<\/ol><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li><span style=\"font-size: x-small\"><font size=\"2\">Run the project and log in using Facebook. You should be taken to the Facebook Site where when you successfully login and grant this app permissions to access this data, then you should be redirected back to the application.<\/font><\/span> <\/li>\n<li><span style=\"font-size: x-small\"><font size=\"2\">When you click the FacebookInfo link, you should see your friends along with their profile pictures.<\/font><\/span> <\/li>\n<\/ul>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/10\/2766.image_thumb_48CB50C3.png\"><font size=\"2\"><img decoding=\"async\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/10\/2766.image_thumb_48CB50C3.png\" width=\"838\" height=\"782\" \/><\/font><\/a><\/p>\n<blockquote>\n<h2><font size=\"2\">Conclusion<\/font><\/h2>\n<p><font size=\"2\">This was an easy way to extend the Social providers and get more information about the logged in user so you can provide a rich experience for the web site users. You can do this with the other Social Providers as well. If you have any questions, please visit the asp.net\/forums or reach me via twitter (@rustd)<\/font><\/p>\n<\/blockquote>\n<p><font size=\"2\"><\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you create a New ASP.NET Project in VS 2013 and choose Individual Accounts, the template shows how you can login with Social providers such as Microsoft Account, Facebook, Google and Twitter. When you login with these Social Providers such as Facebook, you can request more information about the user such as the User\u2019s picture, [&hellip;]<\/p>\n","protected":false},"author":408,"featured_media":58792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[197],"tags":[],"class_list":["post-1164","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aspnet"],"acf":[],"blog_post_summary":"<p>When you create a New ASP.NET Project in VS 2013 and choose Individual Accounts, the template shows how you can login with Social providers such as Microsoft Account, Facebook, Google and Twitter. When you login with these Social Providers such as Facebook, you can request more information about the user such as the User\u2019s picture, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/1164","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/408"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=1164"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/1164\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/58792"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=1164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=1164"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=1164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}