i'm using google-api-php-client to request an access token from the client 0auth flow, but it returns the error "Could not determine client ID from request".
My code is below.
My client_secret.json:
"web": { "client_id":"123", "project_id":"1234", "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":"123456789", "redirect_uris":[ "http://localhost:7777/v1/oauth2callback" ], "javascript_origins":[ "http://localhost:7777" ] } } My auth URL creation:
$client->setAuthConfig(base_path() . '/client_secret.json'); $client->addScope(\Google_Service_Calendar::CALENDAR); $client->setRedirectUri(URL::to('/') . '/v1/oauth2callback'); $client->setAccessType('offline'); $client->setPrompt('consent'); $client->setIncludeGrantedScopes(true); $url = $client->createAuthUrl(); print filter_var($url, FILTER_SANITIZE_URL); I'm then manually going to the URL:
The auth flow all seems to work and returns me back to my url where I try to decode the token:
$code = $request->code; $client = new Google\Client(); $accessToken = $client->fetchAccessTokenWithAuthCode($code); var_dump($accessToken); exit; Which gives me this error:
array(2) { ["error"]=> string(15) "invalid_request" ["error_description"]=> string(43) "Could not determine client ID from request." }