Google YouTube API OOB迁移问题:Loopback模式无法实现原OOB效果
Google OAuth OOB弃用后迁移环回地址的问题
我之前使用Google API的OOB方法,重定向URL为:
urn:ietf:wg:oauth:2.0:oob
但近期该方法已被Google弃用,需迁移至采用环回地址的桌面API。
我尝试了环回地址方法但无法正常工作,相关代码如下:
$client = new Google\Client(); $client->setAuthConfig($dir . 'google/vendor/credentials.json'); $socket = new SocketServer('127.0.0.1','0'); $redirect = $socket->server; //$redirect = 'urn:ietf:wg:oauth:2.0:oob'; // readyonly $client->setScopes(array('https://www.googleapis.com/auth/youtube.readonly','https://www.googleapis.com/auth/youtube.force-ssl','https://www.googleapis.com/auth/yt-analytics.readonly')); $client->setRedirectUri($redirect); $client->setAccessType('offline'); $client->setPrompt('consent'); $client->setIncludeGrantedScopes(true); // incremental auth
若将重定向URL改为http://localhost可以工作,但无法实现原OOB方法的效果。
更新
使用以下代码后出现错误:
$client->setRedirectUri("http://127.0.0.1"); $client->setPrompt('select_account consent');
错误截图:
恳请告知如何实现与原OOB方法一致的效果。
内容的提问来源于stack exchange,提问作者Mohammad Umer
相关产品推荐
相关产品推荐

