Class: OmniAuth::Strategies::Evernote

Inherits:
OAuth
  • Object
show all
Defined in:
lib/omniauth/strategies/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

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.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :client_options (Hash, {})

    Options to be passed directly to the OAuth Consumer



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/omniauth/strategies/evernote.rb', line 23

def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
  client_options = {
    :site => 'https://www.evernote.com',
    :request_token_path => '/oauth',
    :access_token_path => '/oauth',
    :authorize_path => '/OAuth.action',
    :oauth_signature_method => 'PLAINTEXT'
  }

  super(app, :evernote, consumer_key, consumer_secret, client_options, options, &block)
end

Instance Method Details

#auth_hashObject



35
36
37
38
39
40
41
# File 'lib/omniauth/strategies/evernote.rb', line 35

def auth_hash
  OmniAuth::Utils.deep_merge(super, {
    'uid' => user_data.id,
    'user_info' => ,
    'extra' => user_data
  })
end

#user_dataObject



50
51
52
53
54
55
56
# File 'lib/omniauth/strategies/evernote.rb', line 50

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_infoObject



43
44
45
46
47
48
# File 'lib/omniauth/strategies/evernote.rb', line 43

def 
  {
    'name' => user_data.name,
    'nickname' => user_data.username,
  }
end