Reputation: 1641
EDIT
We have informed google about this and they solved it. Now error dissappeared, but $service->accounts->insert
now returns just null
instead of the account.
I am trying to insert an account via Google Mirror API. So what am I doing:
Client
$client = new Google_Client();
$client->setApplicationName($name);
$client->setClientId($client_id);
$client->setDeveloperKey($key);
Service
$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);
Inserting an account
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;
}
And the var_dump show me this
Error calling POST https://www.googleapis.com/mirror/v1/accounts/USER_TOKEN/ACCOUNT/EMAIL?key=DEVELOPERS_KEY: (400) Invalid Value
I am not sure what I am doing wrong... I have tried many things. Not sure what to check. I am trying to authenticate user from the Glass Store in our web app and insert an account, but this happens.
Thank you!
Upvotes: 0
Views: 153
Reputation: 1924
I am fairly certain you don't have access to this API before your app has been accepted to the Glassware "store".
See: https://developers.google.com/glass/develop/gdk/authentication
Upvotes: 1
Reputation: 6034
This error usually happens when the accountType
you are using does not match the one that was entered in the MyGlass backend: make sure you let the review team of the accountType
that you want to use and double check for typos.
Upvotes: 1