google-api-ruby-client

With Google API Client, how to create client

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 07:44:45
问题 I'm working to use the Google API Client: https://github.com/google/google-api-ruby-client Specifically, I want to access Google Contacts via the Google API client using the following google_contacts_api.rb : https://gist.github.com/lightman76/2357338dcca65fd390e2 I am trying to use google_contacts_api.rb like so (x is intentional and is actually the correct keys): require './lib/google_contacts_api.rb' auth = User.first.authentications.first client = OAuth2::Client.new('x', 'x', :site =>

How can I authorize a Google Service Account without the default credentials file?

隐身守侯 提交于 2019-12-20 10:58:53
问题 I have a Google Service Account that my app uses to retrieve data from Google Analytics. When I created the account I downloaded a client_secrets file with all the necessary information for authorization via OAuth, and I recorded the path to this file in an environment variable called GOOGLE_APPLICATION_CREDENTIALS as per Google's documentation. I can now get an authenticated client like this: authorization = Google::Auth.get_application_default(scopes) This method reads the credentials out

Creating draft via Google Gmail API

扶醉桌前 提交于 2019-12-17 14:57:34
问题 I am trying to create a draft message for a logged in user but keep getting the error Missing draft message when I run the below require 'google/api_client' client = Google::APIClient.new client.authorization.client_id = ENV['GOOGLE_CLIENT_ID'] client.authorization.client_secret = ENV['GOOGLE_CLIENT_SECRET'] client.authorization.grant_type = 'refresh_token' client.authorization.refresh_token = User.last.refresh_token token = client.authorization.fetch_access_token! gmail = client.discovered

#next_sync_token fo Google Calendar Events always return nil

守給你的承諾、 提交于 2019-12-13 12:30:00
问题 I created 3 events in Calendar, then I run response = @client.execute!( :api_method => @calendar_api.events.list, :parameters => { :calendarId => "primary", :maxResults => 10, :singleEvents => true, :orderBy => 'startTime'} ) I received 3 items but #next_sync_token method called on response.data returns nil (# next_page_token also returns nil but in this case it is correct). I tried to set :fields parameter to "nextSyncToken" but still nothing. I also made some updates on that events and

add calendar to another user's calendar list

耗尽温柔 提交于 2019-12-13 02:37:30
问题 Not sure if this is possible or if anyone has managed to do this. I have user with super admin access, with which I can create a new user for my domain. However I also want to add a couple of calenders to the created user's calendar list. When I create a user I authenticate using my super admin, but then I can't add a calendar to the user's calendar list since I am not logged in as the user. Is it possible to do this as the super admin, or do I have to logout and authenticate as the created

Ruby real time google analytics API

…衆ロ難τιáo~ 提交于 2019-12-12 14:27:28
问题 I am trying to get activeVisitors with the google-api-ruby-client. The client is listed in the real time google analytics API docs here however I see nothing in the docs about using it for real time api. I see the function discovered_api however I see no list for posisble parameters for the API name. Example for Regular Analytics API: # Get the analytics API analytics = client.discovered_api('analytics','v3') Does anyone know how to use this client to get real time active visitors? Here is

Rails: Send email using Gmail API with attachment return only encoded file not

笑着哭i 提交于 2019-12-12 14:23:48
问题 I am trying to send an email using gmail API. My Ruby code as you can see below works well without an attachment: client = google_client user_id token = Token.find_by_user_id(user_id) access_token = token.access_token gmail = Google::Apis::GmailV1::GmailService.new gmail.authorization = client message = Mail.new message.date = Time.now message.subject = 'Supertram p' message.body = "<p>Hi Alex, how's life?</p>" message.content_type = 'text/html' message.from = self.email message.to = 'email

YouTube API v3 with OAuth2: update and delete fail with “Insufficient Permission” error

寵の児 提交于 2019-12-12 10:46:00
问题 I am trying to update and delete videos using the YouTube API v3 with OAuth2 for authentication via the google-api-client (0.6.4) Ruby gem. However, when I attempt to execute either of these two actions, I see the following error message: Google::APIClient::ClientError: Insufficient Permission Here's the odd thing: Using the exact same authentication procedure as with update and delete , I can insert (upload) successfully, no problem! So, I do not believe this is a problem with my

google-api-ruby-client The current user has insufficient permissions to perform the requested operation

北城以北 提交于 2019-12-11 08:18:37
问题 I am using the google-api-ruby-clientgoogle-api-ruby-client for my backend server to validate the android inapppurchase code (see below): require 'google/api_client' require 'google/api_client/client_secrets' require 'google/api_client/auth/installed_app' API_VERSION = 'v1.1' service_account_email = 'xxx@developer.gserviceaccount.com' # Email of service account key_file = 'xxx.p12' # File containing your private key key_secret = 'notasecret' # Password to unlock private key scope_url = 'https

Google Sheets API v4 service_account - forbidden: The caller does not have permission (Google::Apis::ClientError)

烈酒焚心 提交于 2019-12-11 05:56:07
问题 Ruby: 2.3.1 Rails: 5.0.0 I need to access and update my private Google Sheet through Google Sheets API. Eventually this shall be done by a recurring background job in my Rails application. Hence I have setup a service account in my Google Cloud Console. But to start playing with Google Sheets API I have created a script: require 'google/apis/sheets_v4' ENV["GOOGLE_ACCOUNT_TYPE"] = 'service_account' ENV["GOOGLE_CLIENT_EMAIL"] = '<client_email_from_downloaded_json_here>' ENV["GOOGLE_PRIVATE_KEY