Integration of MVC 4 OAuth. What's next and how to get information from a data provider?

I found many posts and articles with very detailed information on how to configure the MVC 4 application for integration with any social network provider and how to authenticate users, but what next? How to get information about an authenticated user, for example? The simplest task that comes to my mind is how to get some information about an authenticated user - name, surname, avatar address, friends list, etc.?

Update:

  • Below is an article and an article that has a piece of the world
  • Useful article How to interact with Facebook
+5
source share
1

OAuth , . , . , , .

, , , FirstName LastName, , . , ExternalLoginCallback result.ExtraData:

[AllowAnonymous]
public ActionResult ExternalLoginCallback(string returnUrl)
{
    AuthenticationResult result = OAuthWebSecurity.VerifyAuthentication(Url.Action("ExternalLoginCallback", new { ReturnUrl = returnUrl }));
    if (!result.IsSuccessful)
    {
        return RedirectToAction("ExternalLoginFailure");
    }

    if (OAuthWebSecurity.Login(result.Provider, result.ProviderUserId, createPersistentCookie: false))
    {
        return RedirectToLocal(returnUrl);
    }

    if (User.Identity.IsAuthenticated)
    {
        // Here you could use result.ExtraData dictionary
        string name = result.ExtraData["name"];


        // If the current user is logged in add the new account
        OAuthWebSecurity.CreateOrUpdateAccount(result.Provider, result.ProviderUserId, User.Identity.Name);
        return RedirectToLocal(returnUrl);
    }
    else
    {
        // User is new, ask for their desired membership name
        string loginData = OAuthWebSecurity.SerializeProviderUserId(result.Provider, result.ProviderUserId);
        ViewBag.ProviderDisplayName = OAuthWebSecurity.GetOAuthClientData(result.Provider).DisplayName;
        ViewBag.ReturnUrl = returnUrl;
        return View("ExternalLoginConfirmation", new RegisterExternalLoginModel { UserName = result.UserName, ExternalLoginData = loginData });
    }
}

. .

+7

All Articles