Tag: google api

如何使用Gmail Api获取邮件列表?

我想访问消息列表 宾语: 2.0.0-p481 :008 > g.gmail_api.users.messages.list => # 我是这个API的新手,无法了解如何使用Gmail API。 谢谢

Google OAuth 2 redirect_uri_mismatch – OmniAuth Rails应用

我在使用Rails应用validationGoogle帐户时遇到问题。 我正在使用带有Devise的omn​​iauth-google-oauth2 gem 。 我尝试访问Google帐户时始终收到此错误消息: Error: redirect_uri_mismatch The redirect URI in the request: http://localhost:3000/users/auth/google_oauth2/callback did not match a registered redirect URI 我确信我的Google控制台应用中注册的重定向URI是正确的,与请求的相同,就像这样: 那么这里的主要问题是什么?

访问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”}}> […]

在Rails中,是否可以限制谁可以使用API​​登录谷歌?

是否可以仅允许某些Google帐户登录? 例如myname@mycompany.com是通过谷歌主机(他们实际上是谷歌帐户)。 我希望只有@mycompany用户才能登录这可能吗? 你用devise或google api做到这一点吗? 谢谢 :)

客户端未经授权使用此方法检索访问令牌

我在Ruby on Rails项目中有一个自定义仪表板,其中包含从Google Analytics收集的数据。 我使用Google Analytics Reporting V4 API和服务帐户进行身份validation。 如果我没有模仿用户authorization.sub = ‘xxx@mail.com’ ,我的代码运行良好。如果我这样做,我会收到unauthorized_client错误,但不是所有时间。 有时它有效,有时不行。 这是我的代码: scope = [Google::Apis::AnalyticsreportingV4::AUTH_ANALYTICS_READONLY] view_id = ‘xxxxxx’ ENV[‘GOOGLE_APPLICATION_CREDENTIALS’] = “#{Rails.root}/private/google_analytics_key.json” authorization = Google::Auth::get_application_default(scope) authorization.sub = ‘xxx@mail.com’ analytics = Google::Apis::AnalyticsreportingV4::AnalyticsReportingService.new analytics.authorization = authorization … request = Google::Apis::AnalyticsreportingV4::GetReportsRequest.new(report_requests: report_requests) @result = analytics.batch_get_reports(request) Rails服务器日志输出: Sending HTTP post https://analyticsreporting.googleapis.com/v4/reports:batchGet? Caught error Authorization failed. Server message: […]

如何使用刷新令牌刷新google_oauth2访问令牌?

我有一个RoR应用程序,我使用omniauth和google_oauth2对Google进行身份validation,我要求离线访问。 如何使用刷新令牌请求当前访问令牌? 此外,如果访问令牌不再有效,我该如何刷新它? 我不希望在这种情况下有任何用户界面,当然假设授权尚未被删除。

尝试使用YoutubeV3 API创建实时广播时出现“需要登录”错误

我正在尝试使用google-api-ruby-client创建新的广播 YT = Google::Apis::YoutubeV3 client = YT::YouTubeService.new client.key = ‘my-api-key-here’ metadata = { snippet: { title: ‘test’, scheduled_start_time: ‘2018-02-23T14:50:00.000Z’ }, status: { privacy_status: ‘public’ } } part = ‘snippet’ client.insert_live_broadcast(part, metadata, {}) 当我执行此代码时,我收到Error -# [5] pry(main)> CreateYoutubeBroadcast.execute Sending HTTP post https://www.googleapis.com/youtube/v3/liveBroadcasts?key=my-api-key&part=snippet 401 #<HTTP::Message:0x007f8d5356fdc8 @http_header=#<HTTP::Message::Headers:0x007f8d5356fda0 @http_version="1.1", @body_size=0, @chunked=false, @request_method="POST", @request_uri=#, @request_query=nil, @request_absolute_uri=nil, @status_code=401, @reason_phrase=”Unauthorized”, @body_type=nil, @body_charset=nil, […]

如何从Google People API中删除contact_groups

我们使用people api获取contact_groups列表。 虽然我们使用sync_token,但我们无法获取已删除的组。 但人们列表没有这个问题。 怎么解决? service = Google::Apis::PeopleV1::PeopleServiceService.new service.client_options.application_name = ‘xxx’ service.authorization=Signet::OAuth2::Client.new(credentials) response = service.list_contact_groups(sync_token: xxxx-xxxx-xxxx)

如何在ruby中访问Google Contacts API

我正在努力访问Google Contacts API。首先我尝试了google-api-ruby-client gem但事实certificate它不支持Contacts API 。 下一个镜头是google_contacts_apigem 。 我使用oauth2来访问身份validation密钥( 获取身份validation令牌指南问题 )。 但是在将令牌正确传递给api之后,它产生了一个错误。 `’: undefined method `[]’ for #` (NoMethodError). 这是我的代码。 # get token using oauth2 gem, and use it below in the google_contacts_api. google_contacts_user = GoogleContactsApi::User.new(token) contacts = google_contacts_user.contacts groups = google_contacts_user.groups # group methods group = groups[0] group.contacts puts group.contacts # contact methods puts […]

JSON解析Google API自定义搜索错误

我有以下代码: require ‘rubygems’ require ‘httparty’ require ‘pp’ require ‘json’ class Search include HTTParty format :json end x = Search.get(‘https://www.googleapis.com/customsearch/v1key=AI…&cx=013…=flowers&alt=json’) x = x.to_s result = JSON.parse(x) 每次我在谷歌搜索结果上运行它,我得到以下内容: FlowerPlaces.com Delivers Fresh Flowers To Your Place! Order Flowers Online or Call 800-411-9049 for Same Day Flower Delivery.”, “cacheId”=>”v94CIDza4gQJ”}]}’ (JSON::ParserError) from /usr/local/lib/ruby/1.9.1/json/common.rb:148:in `parse’ from gg.rb:15:in `’ 这是JSON试图解析的字符串版本中的同一行: Order Flowers […]