Tag: oauth

OAuth签名validation失败

我在设置具有双腿身份validation的oauth提供程序时遇到了一些问题。 我正在使用oauth-plugin gem和oauth gem,除了我的“更新”请求之外,一切正常。 签名validation过程一直失败。 这是我正在做的事情: 在客户端,我正在使用 oauth = OAuth::AccessToken.new(OAuth::Consumer.new(app_key, app_secret, :site => @api_endpoint)) oauth.get(“http://localhost/api/v1/users/1”) oauth.post(“http://localhost/api/v1/users”, {:email => “testemail@mysite.com”}) oauth.put(“http://localhost/api/v1/users”, {:tags => [“some”, “new”, “tags”]}) oauth.delete(“http://localhost/api/v1/users/1”) 获取,发布和删除都经过身份validation,但更新失败。 在服务器端,我设置了ClientApplication类 def self.verify_request(request, options = {}, &block) begin signature = OAuth::Signature.build(request, options, &block) return false unless OauthNonce.remember(signature.request.nonce, signature.request.timestamp) value = signature.verify value rescue OAuth::Signature::UnknownSignatureMethod => e false end […]

OAuth gem未签署请求

我正在使用rubuth gem for OAuth(http://oauth.rubyforge.org/),我无法让它为我试图点击的提供者创建授权头。 这是我的代码: consumer = OAuth::Consumer.new(auth[:consumer_key], auth[:consumer_secret], { :site => ‘http://api.rdio.com’, :scheme => :header }) access_token = OAuth::AccessToken.new(consumer) ap access_token.post(‘/1’, :method => ‘search’, :query => ‘Robert’, :types => ‘User’) 发生请求时,呼叫中不存在标头。 # [ [0] “*/*” ], “user-agent” => [ [0] “Ruby” ], “content-length” => [ [0] “0” ], “content-type” => [ [0] “application/x-www-form-urlencoded” ] […]

门卫没有网络视图

我正在使用Rails为移动应用程序编写API,而OAuth似乎是处理用户授权的标准方法。 如果我正确理解了Doorkeeper文档,则需要用户在授予移动应用程序访问权限之前登录该网站。 可能情况下的问题是,确实没有任何网站(可能在未来,但现在只是api)。 我想在ios应用程序中处理用户创建/登录等。 这让我想知道OAuth在这里是否是正确的解决方案?

使用Ruby为Gmail IMAP访问生成SASL XOAUTH2客户端响应

我正在尝试使用Ruby中的XOAUTH2通过IMAP访问我的Gmail电子邮件。 通过使用OAuth 2.0和oauth2 gem进行身份validation,我已经成功生成了访问令牌(和刷新令牌)。 我将使用gmail_xoauth通过IMAP访问Gmail。 因此,我现在需要根据Gmail XOAuth2文档生成SASL初始客户端响应: The SASL XOAUTH2 initial client response has the following format: base64(“user=” {User} “^Aauth=Bearer ” {Access Token} “^A^A”) using the base64 encoding mechanism defined in RFC 4648. ^A represents a Control+A (\001). 我不清楚我是如何在字符串中表示“Control + A”的。 我只是使用^A ? key = Base64.encode64(“user=#{email}^Aauth=Bearer #{access_token_obj.token}^A^A”) 这个python脚本使用\1代替^A 我也试过\001 。 无论我尝试什么,在使用结果validation(在irb中)时,我得到: >> imap = Net::IMAP.new(‘imap.gmail.com’, […]

Google OAuth访问令牌

OAuth和Google让我很困惑。 我花了很长时间才得到refresh_token来创建一个新的access_token。 然后找出refresh_token也过期了? 有什么意义!!! 我需要做的就是坚持使用有效的access_token与legato一起使用。 这是我手动输入终端以检索OAUTH代码的内容: client = OAuth2::Client.new(‘GA_CLIENT_ID’, ‘GA_SECRET_KEY’, { :authorize_url => ‘https://accounts.google.com/o/oauth2/auth’, :token_url => ‘https://accounts.google.com/o/oauth2/token’ }) client.auth_code.authorize_url({ :scope => ‘https://www.googleapis.com/auth/analytics.readonly’, :redirect_uri => ‘http://localhost’, :access_type => ‘offline’, :approval_prompt=> ‘force’ }) 然后我在我的浏览器中手动输入输出的URL。 我将返回的OAUTH代码导出为env变量并获取访问令牌: access_token = client.auth_code.get_token(ENV[‘GA_OAUTH_CODE’], :redirect_uri => ‘http://localhost’) 然后我可以访问access_token和refresh_token: begin api_client_obj = OAuth2::Client.new(ENV[‘GA_CLIENT_ID’], ENV[‘GA_SECRET_KEY’], {:site => ‘https://www.googleapis.com’}) api_access_token_obj = OAuth2::AccessToken.new(api_client_obj, ENV[‘GA_OAUTH_ACCESS_TOKEN’]) self.user = Legato::User.new(api_access_token_obj) […]

链接在身份validation和聚合数据中

我正在使用Ruby on Rails构建一个Web应用程序,我希望我的用户对来自Linked In(以及其他像Github,Twitter等等)的数据进行身份validation和聚合。 我正在使用这些gem: 设计注册 omn​​iauth-linkedin用于身份validation pengwynn / linkedin用于数据聚合 虽然,Linked In有一个不太好的pin东西。 有没有办法避免它,并从我的用户帐户获取我想要的数据,而无需他们去链接,获取一个引脚并提交给我? 提前致谢。 authentications_controller.rb class AuthenticationsController < ApplicationController def index @authentications = current_user.authentications if current_user end def create omniauth = request.env["omniauth.auth"] authentication = Authentication. find_by_provider_and_uid(omniauth['provider'], omniauth['uid']) if authentication flash[:notice] = "Signed in successfully." sign_in_and_redirect(:user, authentication.user) elsif current_user current_user.authentications. create!(provider: omniauth['provider'], uid: omniauth['uid']) current_user.apply_omniauth(omniauth) flash[:notice] […]

Ruby Gem Twitter – 证书validation失败(Twitter :: Error :: ClientError)

我正在尝试使用rubygem’twitter’,但由于不明原因,我无法让它工作。 这是.rb代码: require ‘twitter’ puts “Greetings, World!” puts “Checkpoint 1” Twitter.configure do |config| config.consumer_key = “xxxxxxx” #removed for posting config.consumer_secret = “xxxxxxx” #removed for posting config.oauth_token = “xxxxxxx” #removed for posting config.oauth_token_secret = “xxxxxxx” #removed for posting end Twitter.verify_credentials puts “Checkpoint 2” 我收到以下错误: Greetings, World! Checkpoint 1 C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:918:in `connect’: SSL_connect returned=1 errno=0 state=SSLv3 read server […]

如何使用oauth与Ruby连接到Google?

有oauth和oauth2gem,但我还没有找到一个用oauth连接谷歌的例子

OpenSSL :: SSL :: SSLError仅限Ubuntu 12.04

我正在使用Evernote Ruby API开发Web应用程序(使用rails和oauth)。 但是在Ubuntu 12.04中运行应用程序时,我收到错误“SSL_connect SYSCALL返回= 5 errno = 0 state = unknown state”。 这只发生在ubuntu 12.04中。 Ubuntu版本<12.04没有这个问题。

Rails双腿OAuth提供商?

我有一个带有我希望保护的API的rails 2.3.5应用程序。 没有用户 – 它是app风格webservice的应用程序(更像是亚马逊服务而不是facebook),所以我想使用两条腿的OAuth方法来实现它。 我一直在尝试使用oauth-plugin服务器实现作为开始: http://github.com/pelle/oauth-plugin …但它建立了期待三条腿(网络重定向流)oauth。 在我深入研究对其进行更改以支持两条腿之前,我想看看是否有更简单的方法,或者是否有人有更好的方法让rails应用程序实现成为一个两条腿的OAuth提供者。