Tag: google api client

使用google_api_client gem在用户的Feed上看不到Google +时刻

我正在尝试使用google api客户端发布到用户的流,我使用下面提到的代码 require ‘google/api_client’ require ‘google/api_client/client_secrets’ require ‘google/api_client/auth/installed_app’ client = Google::APIClient.new client.authorization.client_id = CLIENT_ID client.authorization.client_secret = CLIENT_SECRET client.authorization.access_token = USER_ACCESS_TOKEN plus = client.discovered_api(‘plus’, ‘v1’) moment = { :type => ‘http://schemas.google.com/AddActivity’, :target => { :id => Time.now.to_i.to_s, :description => ‘well this is it’, :name => ‘Well this is it’ } } req_opts = { :api_method => […]

访问Google Plus联系人google-api-ruby-client和omniauth-google-oauth2

我希望从Google Plus获得联系。 我在用 gem “omniauth” gem “omniauth-google-oauth2” 用于身份validation和 gem “google-api-client” 与谷歌apis通信。 到目前为止,身份validation工作正常,我在身份validation后获得了access_token 。 现在问题是我无法找到一种方法来获取我的圈子中的人员列表(我的Google Plus联系人)。 有没有办法做到这一点。 具体来说,我需要知道是否有任何gem更像谷歌的“fb_graph”? 我发现了这个伎俩 https://plus.google.com/u/0/_/socialgraph/lookup/visible/o=%5Bnull%2Cnull%2C%22_UID_%22%5D&rt=j 只需要输入“UID”,您就可以在您的圈子中获取联系人,但仅限他们的姓名和ID。 但我需要更多信息…… 工作流 client = Google::APIClient.new client.authorization.client_id = GOOGLE_CONFIG[:app_id] client.authorization.client_secret = GOOGLE_CONFIG[:app_secret] client.authorization.access_token = token plus = client.discovered_api(‘plus’) data = client.execute( plus.people.list, :collection => ‘connected’, :userId => ‘me’).data 在数据中我收到此消息 {“errors”=>[{“domain”=>”global”, “reason”=>”insufficientPermissions”, “message”=>”Insufficient Permission”}], “code”=>403, “message”=>”Insufficient Permission”}}> […]

在Google云端硬盘API中接收错误403 – 超出未经身份validation的使用的每日限制。 继续使用需要注册

我正在使用Google Drive API进行ruby,我正在尝试将文件插入用户驱动器。 我可以成功插入文件,但是当我尝试获取文件Self Link时,这是返回的URL https://www.googleapis.com/drive/v2/files/1PxrbKaO2xwOonUO0TB0FO3pkZDnSmRKTvIUmXw0vL6w ,表示我已超出未经身份validation的请求数。 好吧,我很确定我已通过身份validation,因为我遵循了所有教程并且代码几乎相同。 谁知道为什么会这样? 为什么我可以插入文件,但无法查看它的Self Link? 以下是用户允许应用程序进行离线访问后,在驱动器中创建文档的代码: SCOPES = [ ‘https://www.googleapis.com/auth/drive’, ‘https://www.googleapis.com/auth/userinfo.email’, ‘https://www.googleapis.com/auth/userinfo.profile’ ] class DriveAuthenticator def self.create_document(user, title, description, parent_title, user_array) client = DriveAuthenticator.initiate_client if user.google_id.present? if DriveAuthenticator.authenticate_client client, user parent_id = get_parent_id client, parent_title file_data = insert_empty_file client, title, description, DOCUMENT_MIME_TYPE, parent_id return file_data.selfLink end end end private […]

为什么Google的自定义搜索API说我在使用Ruby客户端时缺少访问令牌?

我正在尝试通过Google API Ruby客户端使用Google的自定义搜索API 。 我已通过Google API控制台设置了我的API密钥,并且还创建了我的CSE。 根据文档,似乎只要我提供API密钥(我正在做),我就不需要OAuth2身份validation令牌来调用list方法。 但是,当我尝试执行下面的代码时,我收到以下错误: ArgumentError:缺少访问令牌。 我错过了什么? 这是我的代码: # create client client = Google::APIClient.new # Fetch discovery doc search = client.discovered_api(‘custom search’) # Call list method response = client.execute( search.cse.list, ‘key’ => ”, ‘cx’ => ”, ‘alt’ => ‘json’, ‘q’ => ‘hello world’ )

Ruby Google Calendar Integration观看事件/推送通知

以下代码片段打印日历ID的事件,配置了所有日历并尝试在日历上设置观看通知。 一切都有效但手表事件方法。 我收到此错误:apis / core / http_command.rb:212:在`check_status’中:未经授权(Google :: Apis :: AuthorizationError) 这个看起来很奇怪,因为日历和事件检索工作正常。 service = Google::Apis::CalendarV3::CalendarService.new service.client_options.application_name = APPLICATION_NAME service.authorization = authorize # Fetch the next 10 events for the user calendar_id = ‘us7i4kt2to4mpb0b5et1f9f4co@group.calendar.google.com’ response = service.list_events(calendar_id, max_results: 10, single_events: true, order_by: ‘startTime’, time_min: Time.now.iso8601) puts “Upcoming events:” puts “No upcoming events found” if response.items.empty? response.items.each […]

使用Google Oauth2客户端访问API时,Rails 3.2.3中的SSL错误

我是OAuth2的新手,我正试图通过带有Omniauth和Google API客户端的Google API访问用户的Blogger帐户。 我正在使用以下内容: Rails 3.2.3 Ruby 1.9.3 oauth2(0.8.0) omn​​iauth(1.1.1) omn​​iauth-google-oauth2(0.1.13) google-api-client(0.4.6) 当我第一次尝试使用Google凭据对用户进行身份validation时,我收到以下错误: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed 但是,当我在初始化程序中添加了我的CA证书的特定路径时,错误就消失了: provider :google_oauth2, ENV[‘GOOGLE_APP_ID’], ENV[‘GOOGLE_SECRET’], { access_type: “offline”, approval_prompt: “”, scope: ‘https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/blogger’, client_options: { ssl: { ca_file: cert_path } } } 所以,现在我的用户可以使用他们的Google凭据登录,没有任何问题。 我现在看到的问题是,当我尝试使用访问令牌(在用户身份validation期间从Google收到)访问Blogger API时,我再次收到SSL错误。 这是我用来访问API的代码: token = auth.first.oauth_token.access_token # access […]

cron crawler使用Ruby中的Google API将数据插入Google电子表格的授权问题

我的项目是抓取某些网络数据,并在每天早上9点将它们放入我的Google电子表格中。 它必须获得读写权限的授权。 这就是为什么下面的代码位于顶部。 # Google API CLIENT_ID = blah blah CLIENT_SECRET = blah blah OAUTH_SCOPE = blah blah REDIRECT_URI = blah blah # Authorization_code def get_authorization_code client = Google::APIClient.new client.authorization.client_id = CLIENT_ID client.authorization.client_secret = CLIENT_SECRET client.authorization.scope = OAUTH_SCOPE client.authorization.redirect_uri = REDIRECT_URI uri = client.authorization.authorization_uri Launchy.open(uri) # Exchange authorization code for access token $stdout.write “Enter authorization […]