Получение invalid_grant при получении фотографий из фотографий Google - PullRequest
0 голосов
/ 26 ноября 2018
if(isset($access_token) && !empty($access_token)) {
            try {
                $scope = $this->input->get('scope');
               // $scopes = [$scope];

                $client->setAccessToken($access_token);

                    $credentials = array(
                        'client_id' => $config['web']['client_id'],
                        'client_secret' => $config['web']['client_secret'],
                        'refresh_token' => $access_token
                    );

                    $authCredentials = new UserRefreshCredentials($scope, $credentials);

                    // Set up the Photos Library Client that interacts with the API
                    $photosLibraryClient = new PhotosLibraryClient(['credentials' => $authCredentials]);

                    // Iterate over pages of elements
                    $pagedResponse = $photosLibraryClient->listAlbums();
                    print_r($pagedResponse);die;
                    foreach ($pagedResponse->iteratePages() as $page) {
                        foreach ($page as $element) {
                            // doSomethingWith($element);
                        }
                    }


                /*foreach ($response->iterateAllElements() as $album) {
                    // Get some properties of an album
                    $albumId = $album->getId();
                    $title = $album->getTitle();
                    $productUrl = $album->getProductUrl();
                    $coverPhotoBaseUrl = $album->getCoverPhotoBaseUrl();
                    // The cover photo media item id field may be empty
                    $coverPhotoMediaItemId = $album->getCoverPhotoMediaItemId();
                    $isWriteable = $album->getIsWriteable();
                    $totalMediaItems = $album->getTotalMediaItems();
                }*/

            } catch (\Google\ApiCore\ApiException $exception) {
                // Error during album creation
            } catch (\Google\ApiCore\ValidationException $e) {
                // Error during client creation
                echo $exception;
            }
        }

Я могу видеть данные внутри $ photosLibraryClient, но не могу получить данные $ photosLibraryClient-> listAlbums ();

Даже через я могу получить доступ к access_token, не знаю, почему яполучаю странную проблему, пожалуйста, руководство

Получение ошибки

    Type: GuzzleHttp\Exception\ClientException

    Message: Client error: `POST https://oauth2.googleapis.com/token` resulted in a `400 Bad Request` response: { "error": "invalid_grant", "error_description": "Bad Request" } 

Please guide thanks in advance!
...