我试图让OAuth访问令牌将一些数据导入融合表。我正在尝试使用Google API PHP客户端。我创建用于该目的的服务帐户,和我使用的代码,大多是从serviceAccount例如:如何使用Google API PHP客户端获取OAuth2访问令牌?
function access_token()
{
$client = new Google_Client();
$client->setAuthClass ('Google_OAuth2');
//^Don't know if this line is required,
//^but it fails just as well without it.
$client->setApplicationName ('Mysite.dom.ain');
$client->setAssertionCredentials (new Google_AssertionCredentials
( '[email protected]',
array ('https://www.googleapis.com/auth/fusiontables'),
file_get_contents ('path/to/my/privatekey.p12')));
$client->setClientId ('NUMBERS-LETTERS-DASHES.apps.googleusercontent.com');
$client->authenticate();
//^Also fails equally good with and without this line.
return $client->getAccessToken();
}
一点点调试输出显示$client->authenticate()
回报true
,但$client->getAcessToken()
回报null
。没有例外被抛出。我感觉我正在做一些根本性错误的事情。如果是这样,请原谅我的愚蠢,并指向正确的方向。
如何在java代码中获取访问令牌?任何关于它的帮助 – Vartika