Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.0, Linux OS quickstart.php (via https://developers.google.com/calendar/api/quickstart/php) doesn't work #134

Open
Skywalker1-CZ opened this issue Aug 23, 2022 · 4 comments
Assignees

Comments

@Skywalker1-CZ
Copy link

Hi,

when I trying to use GoogleAPI - via this document https://developers.google.com/calendar/api/quickstart/php - so:

php composer.phar require google/apiclient:^2.0
nano quickstart.php (insert the one from URL)
php quickstart.php won't do anything

in PHP Error log I only seen this:

[23-Aug-2022 14:41:54 Europe/Prague] PHP Fatal error:  Uncaught InvalidArgumentException: file "credentials.json" does not exist in /domains1/vx3641300/public/www_root/vendor/google/apiclient/src/Client.php:982
Stack trace:
#0 /domains1/vx3641300/public/www_root/quickstart.php(36): Google\Client->setAuthConfig('credentials.jso...')
#1 /domains1/vx3641300/public/www_root/quickstart.php(82): getClient()
#2 {main}
  thrown in /domains1/vx3641300/public/www_root/vendor/google/apiclient/src/Client.php on line 982

So, I think that isn't right, because on official documentation is this text:
Step 3: Run the sample

Run the sample using the following command:

php quickstart.php

The first time you run the sample, it prompts you to authorize access:

Browse to the provided URL in your web browser.

If you are not already signed in to your Google account, you are be prompted to sign in. If you are signed in to multiple Google accounts, you are asked to select one account to use for the authorization.
Click the Accept button.
Copy the code you're given, paste it into the command-line prompt, and press Enter.

but how can I activate the API, without browsing the URL from quickstart.php ?

Specifications

  • PHP version (php -v): PHP 8.0.22 (cli) (built: Aug 8 2022 11:02:16) ( NTS )
  • OS (Mac/Linux/Windows): PRETTY_NAME="Gentoo/Linux"

Thanks for reply

Filip

@Skywalker1-CZ
Copy link
Author

Edit: with PHP 7.4.30 on the same system - same issue

@NoiseEee
Copy link

NoiseEee commented Oct 4, 2022

Oh, now PHP samples/examples have been entirely removed from this repo, and from Google API documentation (ie: the link in the first post no longer works).

Disheartening, to say the least.

@vinay-google
Copy link

vinay-google commented Oct 4, 2022

Oh, now PHP samples/examples have been entirely removed from this repo, and from Google API documentation (ie: the link in the first post no longer works).

Disheartening, to say the least.

Still available here https://github.com/googleworkspace/php-samples/tree/main/calendar/quickstart

@shakaran
Copy link

You need to create the credentials.json file via Google Cloud Console

The JSON file has the following fields (redacted for privacy):

{
  "installed": {
    "client_id": "someid.apps.googleusercontent.com",
    "project_id": "your-project-name",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_secret": "some-secret",
    "redirect_uris": [
      "http://localhost"
    ]
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants