首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Mendeley自定义OAuth策略

Mendeley自定义OAuth策略
EN

Stack Overflow用户
提问于 2011-05-12 00:25:18
回答 3查看 1.3K关注 0票数 3

门德利有一个很好的API (事实上,他们使用API进行了一次竞赛,但这个问题并不是特定的),它使用了OAuth。

我正试图写一份允许Mendeley认证的策略,并且在这样做时遇到了很多困难。

我转到/auth/mendeley,它将我重定向到Mendeley.com,我进行身份验证,然后它将我重定向到一个只有以下内容的页面

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

他们提到这是一个3段的OAuth,这比OAuth通常所做的需要额外的一步吗?

以下是我所拥有的:

代码语言:javascript
复制
# /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
代码语言:javascript
复制
# lib/mendeley.rb

require 'omniauth/oauth'
require 'multi_json'

module OmniAuth
  module Strategies

    # Omniauth strategy for using oauth2 and mendeley.com

    class Mendeley < OAuth2
      def initialize(app, consumer_key = nil, consumer_secret = nil, &block)
        client_options = {
          :site => 'http://api.mendeley.com'
        }

        super(app, :mendeley, consumer_key, consumer_secret, client_options, &block)
      end
    end
  end
end
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-03-15 05:06:55

票数 0
EN

Stack Overflow用户

发布于 2012-03-14 18:38:56

我知道你很久以前就问过这个问题了,但我自己需要一个OmniAuth插件。因此,我写了一个宝石,应该在未来帮助人们。它的工作原理与其他OmniAuth策略非常相似。

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

票数 1
EN

Stack Overflow用户

发布于 2011-08-02 00:39:43

通过查看此页,它们似乎支持OAuth 1,但在您的代码中,您的子类是OAuth2

你确定他们会支持吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5972048

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档