相关疑难解决方法(0)

使用user_id获取Google+个人资料图片网址

我知道很多社交网络API提供了一种使用user_id或用户名构建用户个人资料图片网址的方法.对于Facebook,它看起来像这样:

http://graph.facebook.com/user_id/picture?type=square

现在Google Plus有这样的东西吗?或者任何其他方式在没有API调用的情况下获取用户的图片?

google-api google-plus

89
推荐指数
5
解决办法
11万
查看次数

在默认MVC5应用程序中的帐户关联步骤中从外部提供商Google和Facebook获取电子邮件

显然,您可以通过在以下FacebookAuthenticationOptions对象中添加范围来向Facebook提供商执行此操作Startup.Auth.cs:

http://blogs.msdn.com/b/webdev/archive/2013/10/16/get-more-information-from-social-providers-used-in-the-vs-2013-project-templates.aspx

List<string> scope = new List<string>() { "email" };
var x = new FacebookAuthenticationOptions();
x.Scope.Add("email");
...
app.UseFacebookAuthentication(x);
Run Code Online (Sandbox Code Playgroud)

如何与Google提供商进行相同的操作?类/对象没有x.Scope属性GoogleAuthenticationOptions!

asp.net-mvc-5 asp.net-identity asp.net-identity-2

25
推荐指数
2
解决办法
2万
查看次数

使用MVC5中的OWIN Oauth进行的Google身份验证不会影响ExternalLoginCallback功能

我目前正在升级我的Google登录流程,以便在他们的OpenID登录方法之前使用OAuth.

到目前为止,我已经确定的步骤是我已将Microsoft.Owin.Security.Google软件包升级到版本2.1.0,因为此版本包含在UseGoogleAuthentication方法中包含选项的功能.

我试图在链接中使用Alex Wheat的解决方案: 从外部身份验证提供程序获取MVC5框架OAuth/OWin身份提供者的ExtraData

Startup.Auth.cs中的代码(也包括Facebook身份验证)来自于:

    var facebookAuthenticationOptions = new FacebookAuthenticationOptions()
        {
            AppId = "MYAPPID",
            AppSecret = "MYSECRET"
        };
        facebookAuthenticationOptions.Scope.Add("email");
        app.UseFacebookAuthentication(facebookAuthenticationOptions);

        app.UseGoogleAuthentication();
Run Code Online (Sandbox Code Playgroud)

对此:

var facebookAuthenticationOptions = new FacebookAuthenticationOptions()
        {
            AppId = "MYAPPID",
            AppSecret = "MYSECRET"
        };
        facebookAuthenticationOptions.Scope.Add("email");
        app.UseFacebookAuthentication(facebookAuthenticationOptions);


        var googleOAuth2AuthenticationOptions = new GoogleOAuth2AuthenticationOptions
        {
            ClientId = "MYCLIENTID",
            ClientSecret = "MYSECRET",
            CallbackPath = new PathString("/en/Account/ExternalLoginCallback"),
            Provider = new GoogleOAuth2AuthenticationProvider()
            {

            }
        };

        app.UseGoogleAuthentication(googleOAuth2AuthenticationOptions);
Run Code Online (Sandbox Code Playgroud)

在我向Google身份验证添加选项后,我的应用不允许为Google或Facebook调用ExternalLoginCallback操作(不更改Facebook代码,但问题仍会影响它).

在前端,单击外部登录按钮后,页面将我重定向到下面的链接并返回一个空白屏幕

https ....../en/Account/ExternalLoginCallback #__ = _(在=符号之前实际上只有一个下划线,如果我在地址栏上显示它,则SO语法将其删除).

对于Facebook和

HTTPS ....../EN /帐号/ ExternalLoginCallback

对于谷歌.它没有像往常那样点击下面的控制器方法(我试图在这个函数中放置调试断点,并且当有google身份验证选项时它永远不会停止.

    // GET: /Account/ExternalLoginCallback
    [AllowAnonymous]
    public …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc oauth google-authentication owin asp.net-identity

24
推荐指数
3
解决办法
3万
查看次数

如何在c#MVC身份验证中获取google plus个人资料图片

我正在开发一个使用Google登录作为默认提供程序的C#ASP.NET MVC 5应用程序.登录功能正常,我可以获得用户的电子邮件和名称.我需要的一件事是获取用户的个人资料图片.

我怎样才能做到这一点?

到目前为止,我使用默认的MVC auth"UseGoogleAuthentication".

Microsoft.Owin.Security.Google.GoogleAuthenticationOptions a = new Microsoft.Owin.Security.Google.GoogleAuthenticationOptions();

var googleOption = new GoogleAuthenticationOptions()
{
    Provider = new GoogleAuthenticationProvider()
    {
         OnAuthenticated = (context) =>
         {
              var rawUserObjectFromFacebookAsJson = context.Identity;
              context.Identity.AddClaim(new Claim("urn:google:name", context.Identity.FindFirstValue(ClaimTypes.Name)));
              context.Identity.AddClaim(new Claim("urn:google:email", context.Identity.FindFirstValue(ClaimTypes.Email)));
              return Task.FromResult(0);
         }
    }
};

app.UseGoogleAuthentication(googleOption);
Run Code Online (Sandbox Code Playgroud)

这就是我如何获得电子邮件地址.但是个人资料图片怎么样?

我是否需要使用其他形式的身份验证?

c# asp.net-mvc gmail google-plus

13
推荐指数
2
解决办法
9878
查看次数

您在哪里可以找到GoogleOAuth2AuthenticationOptions?

我觉得我错过了一些非常基本的东西,但我已经有了坚实的努力来解决它.

基本上我试图在这里回答这个问题的答案:https://stackoverflow.com/a/22694372/768952

它使用了GoogleOAuth2AuthenticationOptions对象,我的谷歌搜索应该位于.net4.5框架内: Microsoft.Owin.Security.Google.GoogleOAuth2AuthenticationOptions

但是我的MVC项目是.net 4.5而且它不存在!尽管如此,它应该是:http://www.symbolsource.org/Public/Metadata/NuGet/Project/Microsoft.Owin.Security.Google/2.1.0-rc1/Release/.NETFramework,Version%3Dv4.5/ Microsoft.Owin.Security.Google/Microsoft.Owin.Security.Google/GoogleOAuth2AuthenticationHandler.cs?ImageName=Microsoft.Owin.Security.Google

那么GoogleOAuth2AuthenticationOptions究竟在哪里呢?哈哈

c# asp.net-mvc oauth-2.0

4
推荐指数
1
解决办法
4814
查看次数

在mvc 5中使用google auth时如何检索电子邮件地址?

我只在我的asp.net mvc 5应用中启用了Google Auth.我看到当我被重定向到googles auth屏幕时,我要求获得查看用户名和电子邮件地址的权限.然后我从Google返回,登录,并为我的新用户命名.

我显然已经要求查看电子邮件地址的权限,但默认情况下不会存储.我如何将它存储在users表中?

我已经尝试在startup.auth中编辑选项,但没有任何与电子邮件有关的内容.通过oAuth执行此操作时,您手动要求它.我只是不知道我应该在哪里询问电子邮件地址......

另外,我将如何要求他们的谷歌帐户图片?

asp.net-mvc asp.net-mvc-5

3
推荐指数
2
解决办法
4709
查看次数