Class: OmniAuth::Strategies::Evernote

Inherits:
OAuth
  • Object
show all
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

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



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, 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

Instance Method Details

#auth_hashObject



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' => ,
      'extra' => user_data,
    }
  )
end

#user_dataObject



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_infoObject



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

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