我已经使用 Web API 2 实现了 Google 身份验证并收到以下错误:
The given URL is not allowed by Client_id 'ngAuthApp' configuration.
当我将 AllowedOrigin
更改为 (localhost)
但在 Azure 之后的客户端表中的 api.mytouchstones-uat.net
中不起作用时,此方法有效发布。
我的代码如下:
// Enable the application to use bearer tokens to authenticate users
app.UseOAuthBearerTokens(OAuthOptions);
//Configure Google External Login
googleAuthOptions = new GoogleOAuth2AuthenticationOptions()
{
ClientId = Common.Constant.GoogleClientId,
ClientSecret = Common.Constant.GoogleClientSecret,
Provider = new GoogleAuthProvider()
};
app.UseGoogleAuthentication(googleAuthOptions);
最佳答案
我遇到了同样的问题,这是我的第一个谷歌结果。所以我想如果其他人偶然发现这个问题我可能会回答。
我猜你关注了this guide ,或类似的。
检查您发送到 Facebook/Google 等的redirect_uri 是否与 dbo.Clients 中的AllowedOrigin 相同。
并确保您的 Facebook/Google 应用设置中允许使用相同的 uri。
关于azure - Client_id 不允许给定的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27420497/