Hi!
I'm using the google-api-ruby-client gem, doing the basic calling such as:
@client = Google::Apis::DriveV2::DriveService.new
@client.authorization = @authorization
@client.list_files()
At first I thought that when the access token expires, it will automatically refresh the it using the refresh_token
(and I store the refresh token in database for each user),
as I see in google-api-client-0.9.pre3/lib/google/apis/core/http_command.rb:
def execute(client)
prepare!
proc = block_given? ? Proc.new : nil
begin
Retriable.retriable tries: options.retries + 1,
base_interval: 1,
multiplier: 2,
on: RETRIABLE_ERRORS do |try|
# This 2nd level retriable only catches auth errors, and supports 1 retry, which allows
# auth to be re-attempted without having to retry all sorts of other failures like
# NotFound, etc
auth_tries = (try == 1 && authorization_refreshable? ? 2 : 1)
Retriable.retriable tries: auth_tries,
on: [Google::Apis::AuthorizationError],
on_retry: proc { |*| refresh_authorization } do
return execute_once(client, &proc)
end
end
.....
But this refresh_authorization method is defined as follows:
# Refresh the authorization authorization after a 401 error
#
# @private
# @return [void]
def refresh_authorization
# Handled implicitly by auth lib, here in case need to override
logger.debug('Retrying after authentication failure')
end
Every time only this line is executed, printing this line in the log, but nothing else is done,
and I don't see how that is "handled implicitly by auth lib".
Am I missing some configurations?
Or is there anything else I need to implement myself in order for the automatic refreshing to work?
Thanks!