flickraw gem中的Oauth错误

时间:2015-05-02 10:46:16

标签: ruby-on-rails oauth-2.0 flickr

我正在使用flickraw gem获取我的flickr个人资料中的照片链接,并将其显示在我的博客上。我跟随github上的文档但是它抛出了以下错误

Processing by StaticPagesController#index as HTML
Completed 500 Internal Server Error in 916ms

FlickRaw::OAuthClient::FailedResponse - FlickRaw::OAuthCli
flickraw (0.9.8) lib/flickraw/oauth.rb:156:in `post'
flickraw (0.9.8) lib/flickraw/oauth.rb:92:in `post_form'
flickraw (0.9.8) lib/flickraw/api.rb:58:in `call'
flickraw (0.9.8) lib/flickraw/api.rb:48:in `initialize'
flickraw (0.9.8) lib/flickraw.rb:20:in `flickr'
app/controllers/static_pages_controller.rb:6:in `index'

我的控制器中有以下代码

  class StaticPagesController < ApplicationController
    def index
      token = flickr.get_request_token
      auth_url = token['oauth_authorize_url']
      puts "Open this url in your process to complete the authication process : #{auth_url}"
      puts "Copy here the number given when you complete the process."
      verify = gets.strip

      begin
        flickr.get_access_token(token['oauth_token'], token['oauth_token_secret'], verify)
        login = flickr.test.login
        puts "You are now authenticated as #{login.username}"
      rescue FlickRaw::FailedResponse => e
        puts "Authentication failed : #{e.msg}"
      end
    flickr.photos.search(user_id: "130879534@N07")
  end
end

以下是我的Flickraw.rb

FlickRaw.secure = false
FlickRaw.api_key = "<api key>"
FlickRaw.shared_secret = "<secret>"

0 个答案:

没有答案