小编Dan*_*nko的帖子

Google OAuth 2 错误:redirect_uri_mismatch 随机 url 参数 ASP.NET

我已经通过以下模板在我的网站中通过 VK、Instagram、Facebook 进行了身份验证。但是谷歌需要“重定向网址”。我的重定向网址是这样的:

http://localhost:4588/main/AuthenticationCallback?__provider__=google%2B&__sid__=6f3cc5957e4742758719f9b7decc2c09
Run Code Online (Sandbox Code Playgroud)

参数“ sid ”每次都是随机的。所以我不能给谷歌准确的网址。我试图http://localhost:4588/main/AuthenticationCallback像我在 Instagram 上所做的那样输入,它对 Instagram 有效,但谷歌一直向我显示“400 错误:redirect_uri_mismatch”

我还尝试将http://localhost:4588/main/AuthenticationCallback授权 url 中的 URL 参数作为 URL 参数传递给下面的 google。但在这种情况下,根本不调用方法“IAuthenticationClient.RequestAuthentication”。

你能告诉我我应该为我的 Google 应用输入什么作为“重定向 URL”吗?

使用 OAuth2 的模板类:

public class GoogleAuthenticationClient : IAuthenticationClient
{
    public string appId;
    public string appSecret;
    private string redirectUri;

    public GoogleAuthenticationClient(string appId, string appSecret)
    {
        this.appId = appId;
        this.appSecret = appSecret;
    }

    string IAuthenticationClient.ProviderName
    {
        get { return "google+"; }
    }

    void IAuthenticationClient.RequestAuthentication(HttpContextBase context, Uri returnUrl)
    {
        var APP_ID = this.appId;
        this.redirectUri = …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc google-api oauth-2.0

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

标签 统计

asp.net-mvc ×1

google-api ×1

oauth-2.0 ×1