Sha256: bbd2ea1ea07db358cfc2be5e3d98bcdf2d4c51f0d9319c14a99410ec06983d88

Contents?: true

Size: 1015 Bytes

Versions: 1

Compression:

Stored size: 1015 Bytes

Contents

require 'omniauth/strategies/oauth'

module OmniAuth
  module Strategies
    class Mendeley < OmniAuth::Strategies::OAuth
      option :name, "mendeley"

      option :client_options, {
        :site => 'https://api.mendeley.com',
        :request_token_path => '/oauth/request_token/',
        :access_token_path => '/oauth/access_token/',
        :authorize_path => '/oauth/authorize/',
        :http_method => :get,
        :scheme => :query_string
      }

      uid do
        user_data['profile_id']
      end

      info do
        user_data.delete_if { |k, v| v.nil? || v.length == 0 }
      end

      extra do
        user_data
      end

      def user_data
        @info ||= MultiJson.decode(@access_token.get('/oapi/profiles/info/me').body)['main']
      end

      # For callback_confirmed to true so omniauth-oauth will set the
      # :oauth_verifier during callback
      def callback_phase
        session['oauth'][name.to_s]['callback_confirmed'] = true
        super
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-mendeley-0.2 lib/omniauth/strategies/mendeley.rb