如何在asp.net核心MVC RC2中检索Facebook用户个人资料图片 [英] How to retrieve facebook user profile picture within asp.net core MVC RC2

查看:71
本文介绍了如何在asp.net核心MVC RC2中检索Facebook用户个人资料图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ASP.NET Core MVC RC2我正在尝试检索Facebook用户个人资料图片.为此,我在启动类的Configure方法中添加了以下几行

Using ASP.NET Core MVC RC2 I am trying to retrieve the Facebook user profile picture. To do this I have the following lines in the Configure method of the Startup class

            app.UseFacebookAuthentication(new FacebookOptions()
        {
            AppId = Configuration["Authentication:Facebook:AppId"],
            AppSecret = Configuration["Authentication:Facebook:AppSecret"],
            Scope = { "user_birthday" },
            Fields = { "birthday", "picture" },
        });

在AccountControllers ExternalLoginCallback方法中,我期望在ClaimsPrincipal集合中看到该图片的数据,可以通过info.Principal进行访问,但是我看不到与该图片相关的任何索赔.

In the AccountControllers ExternalLoginCallback method I was expecting to see the data for the picture in the ClaimsPrincipal collection which can be accessed via info.Principal but I cannot see any claim associated with picture.

这是检索Facebook用户个人资料图片的正确方法还是我遗漏了某些东西?

Is this the right way to retrieve the Facebook user profile picture or am I missing something?

推荐答案

使用第三方身份验证,您仅会获得有关用户身份的信息(用户身份验证).

Using 3rd Party Authentication, you are only get information about who user is (user authentication).

使用Facebook身份验证,成功登录后,您会收到对Facebook API的访问令牌和用户数据(声明)的集合,仅来自

Using Facebook Authentication, after successful login you receive an access token to Facebook API and a collection of user data (claims) only from UserInformationEndpoint (https://graph.facebook.com/v2.6/me).

此后,如果要获取其他任何特定于用户的信息(例如您的情况下的用户图片),应调用Facebook API方法-

After that, you should call Facebook API methods if you want to get any other user specific information (like user picture in your case - Facebook Graph API. User Picture).

如果您对声称已完成Facebook登录的ASP.Core实现充满兴趣的内容,请查看

If you are interesting about claims that ASP.Core implementation of Facebook login is filled, looks into CreateTicketAsync method in FacebookHandler class - here the collection of claims is created.

这篇关于如何在asp.net核心MVC RC2中检索Facebook用户个人资料图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆