Class: OmniAuth::Strategies::Evernote
- Defined in:
- lib/omniauth/strategies/oauth/evernote.rb
Overview
Authenticate to Evernote via OAuth and retrieve an access token for API usage
Usage: use OmniAuth::Strategies::Evernote, 'consumerkey', 'consumersecret'
Instance Attribute Summary
Attributes inherited from OAuth
#consumer_key, #consumer_options, #consumer_secret, #name
Instance Method Summary collapse
- #auth_hash ⇒ Object
-
#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ Evernote
constructor
Initialize the Evernote strategy.
- #user_data ⇒ Object
- #user_info ⇒ Object
Methods inherited from OAuth
#callback_phase, #consumer, #request_phase, #unique_id
Constructor Details
#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ Evernote
Initialize the Evernote strategy.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/omniauth/strategies/oauth/evernote.rb', line 15 def initialize(app, consumer_key=nil, consumer_secret=nil, ={}, &block) = { :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, , , &block) end |
Instance Method Details
#auth_hash ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/omniauth/strategies/oauth/evernote.rb', line 26 def auth_hash OmniAuth::Utils.deep_merge( super, { 'uid' => user_data.id, 'user_info' => user_info, 'extra' => user_data, } ) end |
#user_data ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/omniauth/strategies/oauth/evernote.rb', line 43 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 |
#user_info ⇒ Object
36 37 38 39 40 41 |
# File 'lib/omniauth/strategies/oauth/evernote.rb', line 36 def user_info { 'name' => user_data.name, 'nickname' => user_data.username, } end |