Google Drive authentication errors

Google Drive authentication errors

by Michael Woods -
Number of replies: 2
Picture of Core developers

Hi,

Our Google Drive authentication has been working nicely for some years until a recent migration of our moodle site to a different server. Many things on the new server are different to the old one, but the moodle code was not changed at all. The new server is running:

  • Ubuntu (instead of Gentoo)
  • Apache version 2.4.6
  • MySQL version 5.5.35
  • PHP version 5.5.3
  • JSON version 1.3.1

We got this error with full debugging turned on:

 

Exception - Could not json decode the token

More information about this error

Debug info:
Error code: generalexceptionmessage
Stack trace:
  • line 154 of /lib/google/auth/Google_OAuth2.php: Google_AuthException thrown
  • line 104 of /lib/google/auth/Google_OAuth2.php: call to Google_OAuth2->setAccessToken()
  • line 132 of /lib/google/Google_Client.php: call to Google_OAuth2->authenticate()
  • line 121 of /repository/googledocs/lib.php: call to Google_Client->authenticate()
  • line 62 of /repository/repository_callback.php: call to repository_googledocs->callback()

 In the end, I discovered that in lilb/google/io/Google_CurlIO.php, the $headerSize on line 207 was too large, therefore truncating the $responseBody text (starting the text part way through). However, if I reduced the $headerSize by 40 characters, everything is now working. eg.

$headerSize = $headerSize - 40;

I'm wondering if anyone else has come across this yet? Is it the latest version of PHP do you think? Because the moodle code didn't change, and still works perfectly on an older server, so I'm presuming the google api hasn't changed.

I'd love someone else's ideas here, as my fix feels pretty flaky, but I had hundreds of students who suddenly could not submit their assignments via their google drive. mixed

Thanks in advance!
Michael

Average of ratings: -
In reply to Michael Woods

Re: Google Drive authentication errors

by Brett Graham -

I work with Michael. Our Moodle version is 

Moodle releaseHelp with Moodle release
2.6.2+ (Build: 20140411)
In reply to Michael Woods

Re: Google Drive authentication errors

by Yogesh Nahar -

Hi Michael,

I am having the same issue as you did. I am running Moodle v2.6 (Build: 20131118) on a shared hosting. (Blue Host). 

I am still getting this error and unable to fix it. Can you please point out which line I should edit in the curlio.php file?

Here is the debug message:

Exception - Could not json decode the token

More information about this error

Debug info: 

Error code: generalexceptionmessage

Stack trace:

line 153 of /lib/google/auth/Google_OAuth2.php: Google_AuthException thrown

line 104 of /lib/google/auth/Google_OAuth2.php: call to Google_OAuth2->setAccessToken()

line 131 of /lib/google/Google_Client.php: call to Google_OAuth2->authenticate()

line 121 of /repository/googledocs/lib.php: call to Google_Client->authenticate()

line 62 of /repository/repository_callback.php: call to repository_googledocs->callback()

--

I am looking at the lib/Google/curlio.php file and am trying to figure out where to fix this issue. 

Any help here would be greatly appreciated.

Thank you.