googleworkspace / php-samples

PHP samples for Google Workspace APIs
Apache License 2.0
290 stars 349 forks source link

"Invalid token format" error returned when using malformed auth code #12

Closed jabcreations closed 6 years ago

jabcreations commented 6 years ago

(Please search existing issues before creating a new one.)

Sample:

Expected Behavior

Not sure.

Actual Behavior

This error_log file was created:

[] PHP Fatal error: Uncaught InvalidArgumentException: Invalid token format in /home/example1/public_html/temp/calendar/vendor/google/apiclient/src/Google/Client.php:433 Stack trace:

0 /home/example1/public_html/temp/calendar/quickstart.php(39): Google_Client->setAccessToken(Array)

1 /home/example1/public_html/temp/calendar/quickstart.php(52): getClient()

2 {main}

thrown in /home/example1/public_html/temp/calendar/vendor/google/apiclient/src/Google/Client.php on line 433 [] PHP Fatal error: Uncaught InvalidArgumentException: Invalid token format in /home/example1/public_html/temp/calendar/vendor/google/apiclient/src/Google/Client.php:433 Stack trace:

0 /home/example1/public_html/temp/calendar/quickstart.php(39): Google_Client->setAccessToken(Array)

1 /home/example1/public_html/temp/calendar/quickstart.php(52): getClient()

2 {main}

thrown in /home/example1/public_html/temp/calendar/vendor/google/apiclient/src/Google/Client.php on line 433

Steps to Reproduce the Problem

  1. Follow this tutorial using PuTTY: https://developers.google.com/calendar/quickstart/php
  2. When you need to copy the URL select it and right click to copy, THAT triggers the error (apparently).

Specifications

Apparently the tutorial did work as the second time I run php quickstart.php PuTTY displays a list of near-future events from Google Calendar.

erickoledadevrel commented 6 years ago

The problem seems to be that you inadvertently entered an invalid auth code, but the error wasn't clear about that. I'll have a fix out soon.