Skip to content

Commit

Permalink
Merge pull request #11 from erikn69/master
Browse files Browse the repository at this point in the history
Fix readStream authentication/access token
  • Loading branch information
masbug authored Feb 4, 2021
2 parents 1766fcb + fc94ebe commit 5044178
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/GoogleDriveAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,16 @@ public function readStream($path)
$dlurl = $this->getDownloadUrl($file);
$client = $this->service->getClient();
/** @var array|string|object $token */
$token = $client->getAccessToken();
if($client->isUsingApplicationDefaultCredentials()) {
$token = $client->fetchAccessTokenWithAssertion();
} else {
$token = $client->getAccessToken();
}
$access_token = '';
if(is_array($token)) {
if(empty($token['access_token']) && !empty($token['refresh_token'])) {
$token = $client->fetchAccessTokenWithRefreshToken();
}
$access_token = $token['access_token'];
} else {
if(($token = @json_decode($token))) {
Expand Down Expand Up @@ -1009,7 +1016,7 @@ protected function normaliseObject(Google_Service_Drive_DriveFile $object, $dirn
{
$id = $object->getId();
$path_parts = $this->splitFileExtension($object->getName());
$result = [];
$result = ['id'=>$id];
$result['type'] = $object->mimeType === self::DIRMIME ? 'dir' : 'file';

if($this->useDisplayPaths) {
Expand Down

0 comments on commit 5044178

Please sign in to comment.