Zend_Gdata の AuthSub でハマったのでメモ。
問題
Google ドキュメントのスプレッドシートを読み書きするプログラムで認証が通らない。
現象
シート情報を取得する際に "Token invalid - AuthSub token has wrong scope" と怒られる。
$httpClient = Zend_Gdata_AuthSub::getHttpClient($token); $gdClient = new Zend_Gdata_Spreadsheets($httpClient); $feed = $gdClient->getSpreadsheetFeed();//エラー
解決方法
ググったら同じ問題で悩んでいる人がいて、認証時の scope を下記のように 3 つ指定することで動くようになりました。
function getAuthSubUrl() { $next = 'http://www.coolspreadsheetsite.com/welcome.php'; $scope = 'http://spreadsheets.google.com/feeds https://spreadsheets.google.com/feeds http://docs.google.com/feeds'; //$scope = 'https://spreadsheets.google.com/feeds/'; $secure = false; $session = true; return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); }