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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

eliosh created an issue. See original summary.

eliosh’s picture

Status: Active » Needs review
FileSize
772 bytes

I 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.

laszlo.kovacs’s picture

FileSize
684 bytes

Patch #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.

laszlo.kovacs’s picture

FileSize
953 bytes

Playing around with gauth I found two problems:

1. After installing it I receive this message:

Notice: Array to string conversion in drupal_write_record() (line 7297 of /home/laci/www/intra/docroot/includes/common.inc).

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.

laszlo.kovacs’s picture

FileSize
1.36 KB

I am sorry, the initial access type had to be set in function gauth_login_user_login_submit() too. So here the patch goes.

sadashiv’s picture

Status: Needs review » Fixed

I 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

sadashiv’s picture

There 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.

sadashiv’s picture

Hi,

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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.