How to work with Google Drive PHP API?

Good day!
There's an issue with Google Drive API PHP. Registered an app, got CLIENT_ID, CLIENT_SECRET.
Work on the local server.
Added the following code:

<?php

// Call set_include_path() as needed to point to your client library.
set_include_path($_SERVER['DOCUMENT_ROOT'] . '/new1804/google-api-php-client-1.1.7/src/');
require_once 'Google/autoload.php';
require_once 'Google/Client.php';
require_once 'Google/Service/Drive.php';
session_start();

$OAUTH2_CLIENT_ID = 'my CLIENT_ID';
$OAUTH2_CLIENT_SECRET = my CLIENT_SECRET;
$REDIRECT = 'http://localhost/oauth2callback.php';
$APPNAME = "My Project";


$client = new Google_Client();
$client--->setClientId($OAUTH2_CLIENT_ID);
$client->setClientSecret($OAUTH2_CLIENT_SECRET);
//$client->setScopes('https://www.googleapis.com/auth/youtube');
$client->setRedirectUri($REDIRECT);
$client->setApplicationName($APPNAME);
$client->setAccessType('offline');
?>


But the authorization is not happening.

Downloaded quickstart.php. It is not clear how to take credentialsPath and accessToken.

Help who had experience. If there are working examples with minimal functionality (viewing the list file, uploading the file to disk).

Thanks in advance!
July 12th 19 at 17:27
1 answer
July 12th 19 at 17:29
On the local server? where you and Google answers should be directed to him?)) about the tokens read the OAuth2 specification

Find more questions by tags PHP