Sha256: ca2335b91b22f6878738c58cb0686ce52fa662b22aa606feacf1fbf7c378a0f6
Contents?: true
Size: 1.55 KB
Versions: 3
Compression:
Stored size: 1.55 KB
Contents
require 'omniauth/oauth' require 'multi_json' require 'evernote' module OmniAuth module Strategies # Authenticate to Evernote via OAuth and retrieve an access token for API usage # # Usage: # use OmniAuth::Strategies::Evernote, 'consumerkey', 'consumersecret' class Evernote < OmniAuth::Strategies::OAuth # Initialize the Evernote strategy. # # @option options [Hash, {}] :client_options Options to be passed directly to the OAuth Consumer def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) client_options = { :access_token_path => '/oauth', :authorize_path => '/OAuth.action', :oauth_signature_method => 'PLAINTEXT', :request_token_path => '/oauth', :site => 'https://www.evernote.com', } super(app, :evernote, consumer_key, consumer_secret, client_options, options, &block) end def auth_hash OmniAuth::Utils.deep_merge( super, { 'uid' => user_data.id, 'user_info' => user_info, 'extra' => user_data, } ) end def user_info { 'name' => user_data.name, 'nickname' => user_data.username, } end def user_data @user_data ||= begin user_store_url = consumer.site + '/edam/user' client = ::Evernote::Client.new(::Evernote::EDAM::UserStore::UserStore::Client, user_store_url, {}) client.getUser(@access_token.token) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
oa-oauth-0.3.2 | lib/omniauth/strategies/oauth/evernote.rb |
oa-oauth-0.3.0 | lib/omniauth/strategies/oauth/evernote.rb |
oa-oauth-0.3.0.rc3 | lib/omniauth/strategies/oauth/evernote.rb |