I'm trying to get offline access
with Google APIs. I have to pull data from Google Calendar without having the user sign-in everytime.
I've added this to my Gemfile:
gem 'google-api-client', '~> 0.9'
... And added this to my controller:
require 'google/api_client/client_secrets'
class Api::V1::CalendarAccountsController < Api::V1::BaseController
...
And in my action:
client_secrets = Google::APIClient::ClientSecrets.load(
File.join(
Rails.root,
'config',
'client_secrets.json')
)
@auth_client = client_secrets.to_authorization
@auth_client.update!(
:scope => 'https://www.googleapis.com/auth/calendar.readonly',
:redirect_uri => '/{callback URL}',
:additional_parameters => {
"access_type" => "offline",
"include_granted_scopes" => "true"
}
)
redirect_to @auth_client.authorization_uri.to_s
The problem is -- even though I'm specifying "access_type" as "offline", I still don't get asked for offline-access privileges in the Google privileges list (I'm attaching a screenie below).
And here's the page Google loads (no offline-access):
And here's the URL that got generated when I called @auth_client.authorization_uri.to_s
Am I missing something?