Google 身份验证的 Microsoft Owin 实现如何能够在没有应用程序 ID 和应用程序机密的情况下进行身份验证?

How is the Microsoft Owin implementation for Google Authentication able to authentication without an app Id and app secret?

OAuth 框架要求客户端向授权和资源服务器注册。 OAuth 中没有像 Open Id 中那样的发现。

事实上,如果您尝试在不使用任何库的情况下实现 OAuth 客户端,Google 授权服务器是验证 redirect_uri 和您的客户端应用程序的更严格的服务器之一身份。

然而,当您使用 Microsoft Owin Google 身份验证提供程序时,它能够使用 Google 对用户进行身份验证,而无需客户端注册、客户端 ID 和客户端密码,以及适当的redirect_uri 将由 Google 验证。

这是如何运作的? Microsoft 的 Owin 实施如何实现这一目标?

OWIN/Katana 3 中实际上有 2 个不同的 Google 提供商:

  1. GoogleOAuth2AuthenticationHandler:顾名思义,它基于OAuth2。从历史上看,它是最近的一个,并且在 2015 年 7 月仍然支持。

  2. GoogleAuthenticationHandler: based on OpenID 2.0, this one was marked as Obsolete when Google started deprecating its OpenID 2.0 support: https://developers.google.com/identity/sign-in/auth-migration#timetable。该提供程序不再有效,您将被 Google 重定向到一个帮助页面,说明 OpenID 2.0 支持已被删除。

供应商由 Katana "automatically" 根据您在代码中使用的扩展选择:https://github.com/jchannon/katanaproject/blob/master/src/Microsoft.Owin.Security.Google/GoogleAuthenticationExtensions.cs

只有 OpenID 2.0 提供程序允许您通过 Google 进行身份验证而无需先注册您的应用程序:如果您尝试使用 OAuth2 提供程序而不指定 client_idclient_secret, 会抛出异常