This is driving me mental. I have a web application and an associated Google Account. I want the web application to use this Google drive and this google drive ONLY...PERMANENTLY.
I am using google/apiclient:^2.0 I have set up a OAuth 2.0 client ID and downloaded the JSON file.
I have this:
$this->client = new \Google_Client();
$this->client->setClientId('blahblahblah.apps.googleusercontent.com');
$this->client->setAuthConfig(base_path() . '/resources/assets/client_secret.json');
$this->client->setApplicationName('My Web App');
$this->client->setRedirectUri('somewhere');
$this->client->setScopes('https://www.googleapis.com/auth/drive');
return $this->client;
Now when I run...
$authUrl = $this->client->createAuthUrl();
echo '<a href="'.$authUrl.'">Go</a>';
And authenticate I get a Code...
Now my question is...what do I do with that code?
I've tried...$this->client->authenticate('code here');
and also $accessToken = $client->fetchAccessTokenWithAuthCode('code here);
I keep getting either dailyLimitExceededUnreg
or Invalid token format
I'm really confused and frustrated with the Google authentication API and the docs seem way out of date.
Any hints in the right direction would be amazing.
Thanks