3

Mendeleyには、OAuth を使用する優れた API があります (実際、彼らは API を使用してコンテストを開催しましたが、この質問はそれに固有のものではありません)。

Mendeley認証を許可する戦略を書こうとしていますが、そうするのにかなり苦労しています..

/auth/mendeley に移動すると、Mendeley.com にリダイレクトされます。認証すると、これ以外の何もないページにリダイレクトされます。

{"エラー":"コンシューマ キーが見つかりません"}

彼らはこれが 3 レグ 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 < 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
4

3 に答える 3

1

ずいぶん前に質問されたことは知っていますが、Mendeley 用の OmniAuth プラグインが必要でした。その結果、私は将来人々を助ける宝石を書きました。これは、他の OmniAuth 戦略と非常によく似ています。

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

于 2012-03-14T18:38:56.837 に答える
0

自分でやりました - プルリクエスト: https://github.com/intridea/omniauth/pull/587/files#diff-13

于 2012-03-15T05:06:55.657 に答える
0

このページを見ると、OAuth 1 をサポートしているように見えますが、コードでは をサブクラス化していますOAuth2

彼らがそれをサポートしていると確信していますか?

于 2011-08-02T00:39:43.310 に答える