Skip to content

Commit

Permalink
Change the file names expected for developer credentials, and other f…
Browse files Browse the repository at this point in the history
…ixes.
  • Loading branch information
Eric Koleda committed Jul 16, 2018
1 parent 489a31f commit c3ae4b2
Show file tree
Hide file tree
Showing 33 changed files with 215 additions and 613 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ composer.phar
.php_cs.cache
client_secret.json
credentials.json
token.json
application_credentials.json
8 changes: 4 additions & 4 deletions admin-sdk/directory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Before running this quickstart, be sure you have [Composer installed globally](h
composer install
```

### Download Service Account Credentials
### Download Developer Credentials

- Go to [APIs and Services](https://pantheon.corp.google.com/apis/credentials) and click "Create Credentials".
Select "Service Account Key" using the JSON key type, and select "Create".
Once downloaded, rename the credentials file to `~/credentials.json`
- Follow the steps in the quickstart instructions to download your developer
credentials and save them in a file called `credentails.json` in this
directory.

## Run

Expand Down
21 changes: 6 additions & 15 deletions admin-sdk/directory/quickstart.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
// [START admin_sdk_directory_quickstart]
require __DIR__ . '/vendor/autoload.php';

if (php_sapi_name() != 'cli') {
throw new Exception('This application must be run on the command line.');
}

/**
* Returns an authorized API client.
* @return Google_Client the authorized client object
Expand All @@ -26,11 +30,11 @@ function getClient()
$client = new Google_Client();
$client->setApplicationName('G Suite Directory API PHP Quickstart');
$client->setScopes(Google_Service_Directory::ADMIN_DIRECTORY_USER_READONLY);
$client->setAuthConfig('client_secret.json');
$client->setAuthConfig('credentials.json');
$client->setAccessType('offline');

// Load previously authorized credentials from a file.
$credentialsPath = expandHomeDirectory('credentials.json');
$credentialsPath = 'token.json';
if (file_exists($credentialsPath)) {
$accessToken = json_decode(file_get_contents($credentialsPath), true);
} else {
Expand Down Expand Up @@ -60,19 +64,6 @@ function getClient()
return $client;
}

/**
* Expands the home directory alias '~' to the full path.
* @param string $path the path to expand.
* @return string the expanded path.
*/
function expandHomeDirectory($path)
{
$homeDirectory = getenv('HOME');
if (empty($homeDirectory)) {
$homeDirectory = getenv('HOMEDRIVE') . getenv('HOMEPATH');
}
return str_replace('~', realpath($homeDirectory), $path);
}

// Get the API client and construct the service object.
$client = getClient();
Expand Down
105 changes: 0 additions & 105 deletions admin-sdk/groups-migration/quickstart.php

This file was deleted.

99 changes: 0 additions & 99 deletions admin-sdk/groups-settings/quickstart.php

This file was deleted.

101 changes: 0 additions & 101 deletions admin-sdk/licensing/quickstart.php

This file was deleted.

8 changes: 4 additions & 4 deletions admin-sdk/reports/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Before running this quickstart, be sure you have [Composer installed globally](h
composer install
```

### Download Service Account Credentials
### Download Developer Credentials

- Go to [APIs and Services](https://pantheon.corp.google.com/apis/credentials) and click "Create Credentials".
Select "Service Account Key" using the JSON key type, and select "Create".
Once downloaded, rename the credentials file to `~/credentials.json`
- Follow the steps in the quickstart instructions to download your developer
credentials and save them in a file called `credentails.json` in this
directory.

## Run

Expand Down
Loading

0 comments on commit c3ae4b2

Please sign in to comment.