gpt4 book ai didi

.net - Google API YouTube示例-错误:redirect_uri_mismatch

转载 作者:行者123 更新时间:2023-12-03 05:55:15 25 4
gpt4 key购买 nike

我从GitHub克隆了Youtube API示例:

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

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

enter image description here

我下载了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”。我什至不知道它是从哪里来的……看起来好像选择了一些随机端口。

有人以前看过这个书吗?

谢谢,

菲利普

最佳答案

您是否在授权过程的代码中设置了重定向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

关于.net - Google API YouTube示例-错误:redirect_uri_mismatch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44579054/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com