【问题标题】:Use google-api-ruby-client gem have redirect_uri_mismatch error使用 google-api-ruby-client gem 有 redirect_uri_mismatch 错误
【发布时间】:2012-07-31 14:11:30
【问题描述】:

我想在 rails 中使用 this API。

它说应该包含一个授权标头。(使用 oauth2)

所以我使用google-api-ruby-client 这个库,如下所示。 我通过this sample写下面的代码。

@client = Google::APIClient.new
@client.authorization.client_id = CONSUMER_KEY
@client.authorization.client_secret = CONSUMER_SECRET
@client.authorization.scope = 'https://apps-apis.google.com/a/feeds/domain/'
@client.authorization.redirect_uri = "http://#{request.host}:#{request.port.to_s}
                                     /google_app/oauth2callback"

redirect_to @client.authorization.authorization_uri.to_s

但它会导致 redirect_uri_mismatch 错误。
不知道我的用法对不对。

注意:
在使用这个API之前,我已经用Google Openid成功登录了。

【问题讨论】:

    标签: ruby-on-rails


    【解决方案1】:

    可能与OAuth 2.0 sample error when accessing Google API 重复

    问题在于,javascript 缺少端口号。

    【讨论】:

      猜你喜欢
      • 2015-10-31
      • 1970-01-01
      • 2014-12-05
      • 2014-12-04
      • 2020-11-08
      • 2014-08-29
      • 1970-01-01
      • 1970-01-01
      • 2021-01-05
      相关资源
      最近更新 更多