Created
February 11, 2018 16:45
-
-
Save ptsakyrellis/0551d6d95cd5ea0417688bd748e1846e to your computer and use it in GitHub Desktop.
Connect to Google API in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$scope = 'https://www.googleapis.com/auth/analytics.readonly'; | |
$jsonKeyFilePath = '../config/client_secrets.json'; | |
$client = new \Google_Client(); | |
$client->setScopes([$scope]); | |
$client->setAuthConfigFile($jsonKeyFilePath); | |
$client->useApplicationDefaultCredentials(); | |
$client->fetchAccessTokenWithAssertion(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment