google-api-ruby-client

With Google API Client, how to create client

陌路散爱 提交于 2019-12-04 00:17:50
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 => 'https://accounts.google.com') oauth2_object = OAuth2::AccessToken.new(client, auth.token) x = ContactList

Google plus insert activity on stream

对着背影说爱祢 提交于 2019-12-03 17:09:18
Tough time inserting an activity to google plus stream. After referring google developers guide . I found an example for java - https://developers.google.com/+/domains/posts/creating Is there a similar example to execute the activites.insert query using google-api-ruby-client . I followed following steps: Define access to app via omniauth-google-oauth2 GOOGLE_CONSUMER_KEY = google_config['KEY'] GOOGLE_CONSUMER_SECRET = google_config['SECRET'] google_scope = "userinfo.email, userinfo.profile, plus.login, plus.me, plus.media.upload, plus.profiles.read, plus.stream.read, plus.stream.write, plus

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

南楼画角 提交于 2019-12-02 23:54:08
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 of the file, which works locally, but my app is hosted on Heroku where file storage is impossible. The

Webmaster API v3: getting servingLimitExceeded using batch requests

假如想象 提交于 2019-12-02 18:15:42
问题 I'm getting the servingLimitExceeded error message for results within batch but not for an entire batch. For example, I may get 100 records responding with this error and then it starts returning more results. All within the a single batch. If batches are handled internally by Google API, how can I adjust them to not hit the rate limit? I tried adding a 1-second delay between batches but that doesn't change this. I also set retries = 3 on the Ruby client, but I don't know if that means it

Webmaster API v3: getting servingLimitExceeded using batch requests

戏子无情 提交于 2019-12-02 10:59:11
I'm getting the servingLimitExceeded error message for results within batch but not for an entire batch. For example, I may get 100 records responding with this error and then it starts returning more results. All within the a single batch. If batches are handled internally by Google API, how can I adjust them to not hit the rate limit? I tried adding a 1-second delay between batches but that doesn't change this. I also set retries = 3 on the Ruby client, but I don't know if that means it retries a failed batch. I don't think it's retrying individual API calls within the batch, because the

How to download file from google drive api with service account?

有些话、适合烂在心里 提交于 2019-12-01 08:50:42
问题 Hello google hackers! I am using Drive Service app and uploaded file successfully like this: require 'googleauth' require 'google/apis/drive_v2' Drive = Google::Apis::DriveV2 upload_source = "/User/my_user_name/hacking.txt" drive = Drive::DriveService.new # Drive::AUTH_DRIVE is equal to https://www.googleapis.com/auth/drive drive.authorization = Google::Auth.get_application_default([Drive::AUTH_DRIVE]) file = drive.insert_file({title: 'hacking.txt'}, upload_source: upload_source) file has a

Trouble with Google Apps API and Service Accounts in Ruby

天大地大妈咪最大 提交于 2019-12-01 08:32:05
I'm having some trouble getting the sample code for instantiating a Drive Service Account working. I've set up the service account in the API console as directed and included the scope for the ' https://www.googleapis.com/auth/drive ', but running this generates the following error: "Authorization failed. Server message: (Signet::AuthorizationError)". Oddly, if I omit the user_email address it doesn't generate an error. My objective is to be able to do an audit on all the files stored on the organization's Drive, and it's my understanding that using a service account would be the way to get a

Creating a Gmail Draft with Recipients through Gmail API

孤人 提交于 2019-12-01 08:29:16
问题 I have been trying to figure out how to automatically add recipients to a Draft email that is created using the Gmail API through their Ruby library. I can create the draft without any issues but setting the recipients is causing me troubles and I haven't been able to find any good examples showing the best way to add email specific things. Using the Google API playground and pulling in drafts that have already been created, it looks like the structure should be something similar to what is

Trouble with Google Apps API and Service Accounts in Ruby

怎甘沉沦 提交于 2019-12-01 06:42:35
问题 I'm having some trouble getting the sample code for instantiating a Drive Service Account working. I've set up the service account in the API console as directed and included the scope for the 'https://www.googleapis.com/auth/drive', but running this generates the following error: "Authorization failed. Server message: (Signet::AuthorizationError)". Oddly, if I omit the user_email address it doesn't generate an error. My objective is to be able to do an audit on all the files stored on the

Creating draft via Google Gmail API

倾然丶 夕夏残阳落幕 提交于 2019-11-27 16:27:39
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_api('gmail', 'v1') params = { 'userId' => 'me', 'draft' => { 'message' => {'raw' => 'test email' } } } #