【问题标题】:Google API YouTube Sample - Error: redirect_uri_mismatchGoogle API YouTube 示例 - 错误:redirect_uri_mismatch
【发布时间】:2023-03-30 02:20:01
【问题描述】:

我从 GitHub 克隆了 Youtube API 示例:

https://github.com/youtube/api-samples.git

并创建了以下 OAuth 2 客户端 ID:

我下载了 JSON 并将其放入 client-secrets.json

但是,当我执行示例代码时,我得到以下信息:

400. That’s an error.

Error: redirect_uri_mismatch

The redirect URI in the request, http://127.0.0.1:55015/authorize/, does not 
match the ones authorized for the OAuth client. 

我真的很困惑,因为我没有将该 URI 指定为我的“重定向 URI”。我什至不知道它来自哪里……看起来像是选择了一些随机端口。

任何人以前见过这个或有任何见解?

谢谢,

菲利普

【问题讨论】:

    标签: .net json git youtube


    【解决方案1】:

    您是否在授权过程的代码中设置了重定向 uri?

    例如在api-samples/php/my_uploads.php:

    $redirect = filter_var('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'],
      FILTER_SANITIZE_URL);
    $client->setRedirectUri($redirect);
    

    尝试将$redirect 更改为https://yourredirecturi.com/callback

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-12-05
      • 2014-12-04
      • 2020-11-08
      • 2014-08-29
      • 1970-01-01
      • 2021-01-05
      • 2017-04-10
      相关资源
      最近更新 更多