Closed basd82 closed 10 months ago
It seems it is not getting the content of te file, if change this
$client->setAuthConfig($authfile);
to this:
$json = file_get_contents($authfile); $client->setAuthConfig($json);
it works
Hi @basd82 ,
I tried the exact same code as above and I'm not facing any such error. Can you please check on your side what is happening by debugging the decoding the setAuthConfig
method?
Closing this issue as this seems inactive. Please feel free to reopen if the issue still persists.
Riopn
php $client = new Google\Client(); $authfile = 'somepath/client_secret.json'; $client->setAuthConfig($authfile); client->setRedirectUri('https://topsecret.domain.tld/oauth2callback.php'); $client->setAccessType('offline'); // offline access $client->setIncludeGrantedScopes(true); // incremental auth $client->addScope(Google\Service\Fitness::FITNESS_ACTIVITY_READ); $auth_url = $client->createAuthUrl(); header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL)); if (isset($_SESSION['access_token']) && $_SESSION['access_token']) { $client->setAccessToken($_SESSION['access_token']); echo "Ingelogd met access tolken: " . $_SESSION['access_token']; } else { $redirect_uri = 'https://topsecret.domain.tld/oauth2callback.php'; header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL)); }
{ "web": { "client_id": "topsecretstuff.apps.googleusercontent.com", "project_id": "health-42", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_secret": "GOCSPX-topsecretstuff", "redirect_uris": [ "https://topsecret.domain.tld/oauth2callback.php", "https://topsecret.domain.tld/googlelogin.php" ] } }
Environment details
Steps to reproduce
Try to get oath to work The api reports json file is missing but it is there, and it is unchanged like downloaded from google dev.
Code example
google login.php
json auth file