Reputation: 1387
I am using the latest found at Google PHP API library
Authentication started on iOS->get code->send to server->get token all works well. But I Store the token for user locally on the server to be used on behalf of iOS client offline access.
Note: $googleToken contains refresh token as well.
$client = new Google_Client();
$oauth2 = new Google_Service_Oauth2($client);
$client->setApplicationName('MyServer');
$client->setClientId($google_config["clientId"]);
$client->setClientSecret($google_config["clientSecret"]);
$client->setRedirectUri("");
$client->setDeveloperKey($google_config["developerKey"]);
$googleToken = getGoogleToken($user); //locally stored google token for user
$client->setAccessToken($googleToken['token']);
$access_token = $client->getAccessToken();
StoreToken($access_token);
and store access_token again. When it expires though my calls start to fail:
"error" : "invalid_request", "error_description" : "Client must specify either client_id or client_assertion, not both"
I have tried setRefreshToken
and every other combination and still can not get it to work.
What am I doing wrong? I did try to set state offline but not sure if it even matters since I get refresh token as part of initial token.
Upvotes: 2
Views: 1698
Reputation: 1387
Wow.. figured it out. It was actually my own problem. $google_config is a global defined in config file! and I was missing global $google_config;
in the function! as result client_id and secret_id were both missing - The error message though is incorrect to say the least!
Upvotes: 2