具有自定义身份验证的ASP.NET不会从Google OAuth收到电子邮件

问题描述 投票:1回答:1

我的ASP.NET MVC系统不使用ASP.NET标识,所以我使用完全自定义的IPrincipal实现。我必须使用Google OAuth在Google上进行身份验证,然后在外部登录回调中执行自己的业务。

问题是,在用户插入Google的电子邮件和密码并成功登录后,在我的外部登录回调中,我的应用程序将无法从HttpContext.OwinContext()获得用户声明。身份验证。索赔是空的,我只需要用户的电子邮件。

AuthenticationManager from OwinContext

这是我的Startup.Auth.cs

System.Auth.cs

登录后没有电子邮件。

Email isn't available in the user claims

假设Google的OAuth中没有错误,我做错了什么?

还有一件事:有时(在其他计算机上测试)声明会通过用户的邮件和其他一些数据返回给我。但是当我尝试使用许多不同的邮件进行登录时,它们也会停止工作。

以下是我的Google API配置,我启用了Google+ API,但这似乎没有什么区别。

编辑

有时它适用于Chrome的匿名导航。

enter image description here

asp.net-mvc authentication oauth-2.0 google-oauth identity
1个回答
1
投票

像google doc一样使用google api auth的async await方法

https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth

© www.soinside.com 2019 - 2024. All rights reserved.