2017-06-16 174 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

相關問題