Skip to content

Instantly share code, notes, and snippets.

@ptsakyrellis
Created February 11, 2018 16:45
Show Gist options
  • Save ptsakyrellis/0551d6d95cd5ea0417688bd748e1846e to your computer and use it in GitHub Desktop.
Save ptsakyrellis/0551d6d95cd5ea0417688bd748e1846e to your computer and use it in GitHub Desktop.
Connect to Google API in PHP
<?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