Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi to all,
i have a problem with last version of gauth (7.x-1.7) and latest Google Auth library (2.0.2).
Fresh install, configure gauth for use with gcal (https://www.drupal.org/project/gcal) and wrote a simple method to read events from a calendar.
After 1 hour, it gives me error:
Access token is expired. If you are admin then you need to authenticate again. Consider configuring access type to offline.
Obviously i set access to offline in gauth account selection.
Someone has the same problem.
ps. previous version worked fine.
Comment | File | Size | Author |
---|---|---|---|
#5 | gauth.2797735.5.patch | 1.36 KB | laszlo.kovacs |
#3 | gauth.2797735.3.patch | 684 bytes | laszlo.kovacs |
#2 | gauth.2797735.2.patch | 772 bytes | eliosh |
Comments
Comment #2
elioshI found where is the error.
As said here, refresh token is always the same, even when we refresh access token.
So here is a patch to solve the problem.
Comment #3
laszlo.kovacsPatch #2 fails when I want to apply it through .make file. If you copy it outside of modules folder it works.
I fixed the path otherwise didn't touch the code.
Comment #4
laszlo.kovacsPlaying around with gauth I found two problems:
1. After installing it I receive this message:
The reason is that within gauth_login.module in gauth_login_gauth_google_response() function the access token is not transferred to a json. Therefor in the database in gauth_accounts table in acces_token field there is an 'Array' string which is definitely not an access token.
2. After new installation of module and fixing the problem above the refresh_token is not saved in access_token field. To get a refresh token we have to set the access_type to 'offline' before we require the token first time.
The patch #4 fixes both problems and after applying patch #3 and #5 I have no more problem with expired tokens.
Comment #5
laszlo.kovacsI am sorry, the initial access type had to be set in function gauth_login_user_login_submit() too. So here the patch goes.
Comment #6
sadashiv CreditAttribution: sadashiv commentedI changed few things and found that the refresh token is returned only if approval_prompt is force. Have made these changes in the latest 7.x-1.9 version
So this issue is fixed and now if the token is expired then it will autorefresh.
Thanks,
Sadashiv
Comment #7
sadashiv CreditAttribution: sadashiv commentedThere seems to be a glitch in the library. I found a similar issue reported at https://github.com/google/google-api-php-client/issues/1064
So our module seems to be working as designed and token won't expire once library developers fix it. If they don't in near future then I'll give it a try (to fix the library), will wait for sometime. I also reported the same issue at https://github.com/google/google-api-php-client/issues/1102 adding code snippets from the gauth module and explaining what's happening.
Lets wait till they reply and if they fix the library then it's good and if it needs some code change in the module then I'll have a new release.
Thanks,
Sadashiv.
Comment #8
sadashiv CreditAttribution: sadashiv commentedHi,
The issue is fixed. Please apply the patch to the library as mentioned at https://github.com/google/google-api-php-client/pull/1103/files
Thanks,
Sadashiv.