pscott-au / WebService-GoogleAPI-Client

Perl WebService::GoogleAPI::Client Module
https://pscott-au.github.io/WebService-GoogleAPI-Client/
Other
1 stars 2 forks source link

Token refreshed every time due to array returned to Bearer header #15

Closed bgilly1 closed 3 years ago

bgilly1 commented 5 years ago

I noticed that every time I call the API, the token was getting refreshed. I enabled MOJO_USERAGENT_DEBUG and determined the Bearer value in the header initally sent was an "ARRAY(XXXXX)" value.

I believe this code in Credentials.pm is the issue.

sub get_scopes_as_array
{
  my ( $self ) = @_;
  if ( $self->auth_storage->is_set )
  {                                                                                                          # chech that auth_storage initialized fine
    return $self->access_token( $self->auth_storage->get_scopes_from_storage_as_array() );
  }
  else
  {
    croak q/Can get access token for specified user because storage isn't set/;
  }

Perhaps this scopes array should be returned to a different attribute like $self->scopes?

pscott-au commented 5 years ago

Thanks @bgilly1 - I had suspected that the refresh token was always being used when the bearer token should be valid. I shall look into this over the coming days and extend the test cases once I have identified the solution. Thanks for tracing the code to this block.

rabbiveesh commented 3 years ago

That code is totally borked. It's stomping the access_token instead of returning the scopes.

It's fixed on my rabbiveesh/service_account branch, which i hope to merge soon

rabbiveesh commented 3 years ago

This is fixed on CPAN in version 0.23