-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_auth_url.php
More file actions
33 lines (28 loc) · 1.15 KB
/
Copy pathget_auth_url.php
File metadata and controls
33 lines (28 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
/**
* Sample PHP code for youtube.search.list
* See instructions for running these code samples locally:
* https://developers.google.com/explorer-help/code-samples#php
*/
if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
throw new Exception(sprintf('Please run "composer require google/apiclient:~2.0" in "%s"', __DIR__));
}
require_once __DIR__ . '/vendor/autoload.php';
$client = new Google_Client();
$client->setApplicationName('API code samples');
$client->setScopes([
'https://www.googleapis.com/auth/youtube.force-ssl',
]);
// TODO: For this request to work, you must replace
// "YOUR_CLIENT_SECRET_FILE.json" with a pointer to your
// client_secret.json file. For more information, see
// https://cloud.google.com/iam/docs/creating-managing-service-account-keys
$client->setAuthConfig('client_secret_desktop.json');
$client->setAccessType('offline');
// Request authorization from the user.
$authUrl = $client->createAuthUrl();
printf("Open this link in your browser:\n%s\n", $authUrl);
// include __DIR__ . '/templates/auth_code.php';
// $authCode = $_GET["authCode"];
// echo $authCode;
?>