Mendeley定制OAuth战略

Mendeley有一个很棒的API(实际上他们已经使用他们的API进行了比赛,但这个问题并不是特定的),它使用了OAuth。

我正在尝试编写允许Mendeley身份validation的策略,并且这样做有很多麻烦。

我去了/ auth / mendeley,它将我重定向到Mendeley.com,我进行了身份validation,然后它将我重定向到一个没有任何内容的页面但是这个

{“error”:“未找到使用者密钥”}

他们提到这是一个三脚OAuth,是否需要额外的步骤,而不是OAuth通常做的事情?

这是我有的:

# /config/initializers/omniauth.rb module OmniAuth module Strategies # tell omniauth to load the strategy autoload :Mendeley, 'lib/mendeley' end end # gather oauth credentials from the yml file OAUTH = YAML.load_file(File.join(Rails.root, "config", "oauth.yml")) # load all the possible oauth strategies ActionController::Dispatcher.middleware.use OmniAuth::Builder do provider OmniAuth::Strategies::Mendeley, OAUTH['mendeley']['consumer_key'], OAUTH['mendeley']['consumer_secret'] end 

 # lib/mendeley.rb require 'omniauth/oauth' require 'multi_json' module OmniAuth module Strategies # Omniauth strategy for using oauth2 and mendeley.com class Mendeley  'http://api.mendeley.com' } super(app, :mendeley, consumer_key, consumer_secret, client_options, &block) end end end end 

我知道你很久以前问过这个问题,但我自己需要一个OmniAuth插件供Mendeley使用。 结果,我写了一个gem,将来可以帮助人们。 它与其他OmniAuth策略的工作方式非常相似。

https://github.com/fractaloop/omniauth-mendeley

通过查看此页面 ,看起来它们支持OAuth 1,但在您的代码中,您OAuth2

你确定他们支持吗?

自己做了 – 拉请求: https : //github.com/intridea/omniauth/pull/587/files#diff-13

Interesting Posts