Reputation: 114
I'm having a hard time integrating Google Contacts into my Ruby (version 2.2.10) on Rails 5 (version 5.1.5) App.
When I execute the following code block, I receive "ArgumentError: unknown keyword: person_fields".
people = Google::Apis::PeopleV1::PeopleService.new
people.authorization = auth_client
response = people.list_person_connections('people/me', page_size: 10,
person_fields: 'names,emailAddresses')
To rectify the problem, I tried using the following gem versions:
gem 'google-api-client', '~> 0.11'
gem 'google-api-client', '~> 0.8'
gem 'google-api-client'
I still receive the error no matter which version of the gem I use.
Below is the code in its entirety:
require 'google/apis/people_v1'
require 'google/api_client/client_secrets'
client_secrets = Google::APIClient::ClientSecrets.load 'client_secret_1088824912015-f8asojku302s0mvcijgj7takse8pg8rg.apps.googleusercontent.com.json'
auth_client = client_secrets.to_authorization
auth_client.update!( :scope => 'https://www.googleapis.com/auth/contacts.readonly', :redirect_uri => 'http://localhost:3000/oauth2callback', :additional_parameters => { "access_type" => "offline", "include_granted_scopes" => "true" } )
auth_uri = auth_client.authorization_uri.to_s
# To exchange an authorization code for an access token, use the fetch_access_token! method:
auth_client.code = #auth_code#
auth_client.fetch_access_token!
people = Google::Apis::PeopleV1::PeopleService.new
people.authorization = auth_client
response = people.list_person_connections('people/me', page_size: 10, person_fields: 'names,emailAddresses')
Any assistance would be greatly appreciated.
Upvotes: 0
Views: 473
Reputation: 167
Just to clarify for any future readers, Ray Baxte linked to docs corresponding to version 0.9.19
of the google-api-client
gem - the current version is 0.27.1
I'm using 0.26.0
and the correct argument is person_fields
- this obviously changed somewhere between 0.9.19
and 0.26.0
I follow the documentation in the generated API method definitions: https://github.com/googleapis/google-api-ruby-client/blob/0.27.1/generated/google/apis/people_v1/service.rb#L591
Upvotes: 2
Reputation: 3210
The correct attribute is fields
not person_fields
. See docs here.
Upvotes: 1