Mendeley Custom OAuth Strategy

Mendeley has an excellent API (in fact, they put up a contest using their API, this question is not specific to this), which uses OAuth.

I'm trying to write a strategy that allows Mendeley Authentication, and I'm having a lot of trouble.

I go to / auth / mendeley, it redirects me to Mendeley.com, I authenticate, then redirects me to a page that has nothing, but it

{"error": "Consumer key not found"}

They mention that this is 3 OAuth, this is something that requires an extra step, what does OAuth usually do?

Here is what I have:

# /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
+3
source share
3 answers

, , OmniAuth Mendeley. , . OmniAuth.

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

+1

Looking at this page , it looks like they support OAuth 1, but in your code you are a subclass OAuth2.

Are you sure they support him?

0
source

All Articles