2017-06-16 78 views
0

我克隆从GitHub的Youtube API示例:谷歌API YouTube的样本 - 错误:redirect_uri_mismatch

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”。我甚至不知道它来自哪里......它看起来像是一些随机端口被选中。

以前有人看过这个或有什么见解吗?

感谢,

菲利普

回答

1

你设置您的重定向URI在授权过程中的代码?

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

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

尝试改变$redirecthttps://yourredirecturi.com/callback