修改
我们已经通知了谷歌,他们解决了这个问题。现在错误消失了,但$service->accounts->insert
现在只返回null
而不是帐户。
我正在尝试通过Google Mirror API插入帐户。那我在做什么:
客户端
$client = new Google_Client();
$client->setApplicationName($name);
$client->setClientId($client_id);
$client->setDeveloperKey($key);
服务
$service = new Google_Service_Mirror($client);
$key = file_get_contents($key_file_location);
$cred = new Google_Auth_AssertionCredentials(
$service_account_name,
[
'https://www.googleapis.com/auth/glass.thirdpartyauth'
],
$key
);
$client->setAssertionCredentials($cred);
if($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion($cred);
}
$_SESSION['service_token'] = $client->getAccessToken();
// THIS IS NOT WORKING
$acc = insert_account($service, $user_token, $user_mail);
插入帐户
function insert_account($service, $userToken, $email) {
$accountType = 'do.sli';
$userDataArray= array();
$userData1= new Google_Service_Mirror_UserData();
$userData1->setKey('some');
$userData1->setValue('data');
$userDataArray[]=$userData1;
$authTokenArray= array();
$authToken1= new Google_Service_Mirror_AuthToken();
$authToken1->setAuthToken('randomtoken');
$authToken1->setType('randomType');
$authTokenArray[]=$authToken1;
$postBody = new Google_Service_Mirror_Account();
$postBody->setUserData($userDataArray);
$postBody->setAuthTokens($authTokenArray);
$postBody->setFeatures(['access']);
try {
$account = $service->accounts->insert($userToken, $accountType, $email, $postBody);
} catch (Exception $e) {
var_dump($e->getMessage());
}
return $account;
}
var_dump告诉我
Error calling POST https://www.googleapis.com/mirror/v1/accounts/USER_TOKEN/ACCOUNT/EMAIL?key=DEVELOPERS_KEY: (400) Invalid Value
我不确定我做错了什么......我尝试了很多东西。不知道该检查什么。我试图在我们的网络应用程序中从Glass Store验证用户并插入一个帐户,但这种情况会发生。
谢谢!
答案 0 :(得分:1)
当您使用的accountType
与MyGlass后端中输入的accountType
不匹配时,通常会发生此错误:请确保您允许{{1}}的审核小组使用错误检查错别字。
答案 1 :(得分:1)
我相当肯定,在您的应用被Apple系统"商店"
接受之前,您无法访问此API。请参阅:https://developers.google.com/glass/develop/gdk/authentication