omniauth-evernote 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +14 -0
- data/Rakefile +7 -0
- data/lib/omniauth-evernote.rb +2 -0
- data/lib/omniauth-evernote/version.rb +5 -0
- data/lib/omniauth/strategies/evernote.rb +37 -0
- data/omniauth-evernote.gemspec +24 -0
- data/spec/omniauth/strategies/evernote_spec.rb +73 -0
- data/spec/spec_helper.rb +8 -0
- metadata +114 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2011 Szymon Nowak
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Omniauth Evernote
|
2
|
+
|
3
|
+
This is OmniAuth strategy for authenticating to Evernote.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
By default the strategy uses `http://www.evernote.com` site. In development you'll want to use `https://sandbox.evernote.com` instead. To do it you'll
|
8
|
+
need to pass `site` option:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
use OmniAuth::Builder do
|
12
|
+
provider :evernote, ENV['EVERNOTE_KEY'], ENV['EVERNOTE_SECRET'], :client_options => { :site => 'https://sandbox.evernote.com' }
|
13
|
+
end
|
14
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'omniauth/strategies/oauth'
|
2
|
+
require 'evernote'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Evernote < OmniAuth::Strategies::OAuth
|
7
|
+
option :name, 'evernote'
|
8
|
+
option :client_options, {
|
9
|
+
:site => 'https://www.evernote.com',
|
10
|
+
:request_token_path => '/oauth',
|
11
|
+
:access_token_path => '/oauth',
|
12
|
+
:authorize_path => '/OAuth.action'
|
13
|
+
}
|
14
|
+
|
15
|
+
uid { raw_info.id }
|
16
|
+
|
17
|
+
info do
|
18
|
+
{
|
19
|
+
'name' => raw_info.name,
|
20
|
+
'nickname' => raw_info.username,
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
extra do
|
25
|
+
{ :raw_info => raw_info }
|
26
|
+
end
|
27
|
+
|
28
|
+
def raw_info
|
29
|
+
@raw_info ||= begin
|
30
|
+
user_store_url = consumer.site + '/edam/user'
|
31
|
+
client = ::Evernote::Client.new(::Evernote::EDAM::UserStore::UserStore::Client, user_store_url, {})
|
32
|
+
client.getUser(access_token.token)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omniauth-evernote/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Szymon Nowak"]
|
6
|
+
gem.email = ["szimek@gmail.com"]
|
7
|
+
gem.description = %q{OmniAuth strategy for Evernote}
|
8
|
+
gem.summary = %q{OmniAuth strategy for Evernote}
|
9
|
+
gem.homepage = "https://github.com/szimek/omniauth-evernote"
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "omniauth-evernote"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Omniauth::Evernote::VERSION
|
17
|
+
|
18
|
+
gem.add_runtime_dependency 'omniauth-oauth', '~> 1.0'
|
19
|
+
gem.add_runtime_dependency 'evernote', '~> 1.1.0'
|
20
|
+
gem.add_runtime_dependency 'multi_json', '~> 1.0.4'
|
21
|
+
|
22
|
+
gem.add_development_dependency 'rspec', '~> 2.7'
|
23
|
+
gem.add_development_dependency 'rake'
|
24
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
# Fix OpenStruct in Ruby 1.8
|
5
|
+
if RUBY_VERSION <= "1.9"
|
6
|
+
class OpenStruct
|
7
|
+
undef id
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe OmniAuth::Strategies::Evernote do
|
12
|
+
before do
|
13
|
+
@consumer_key = 'key'
|
14
|
+
@consumer_secret = 'secret'
|
15
|
+
end
|
16
|
+
|
17
|
+
subject do
|
18
|
+
args = [@consumer_key, @consumer_secret, @options].compact
|
19
|
+
OmniAuth::Strategies::Evernote.new(nil, *args)
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#consumer' do
|
23
|
+
it 'has correct Evernote site' do
|
24
|
+
subject.consumer.options[:site].should eq('https://www.evernote.com')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'has correct request token url' do
|
28
|
+
subject.consumer.options[:request_token_path].should eq('/oauth')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'has correct access token url' do
|
32
|
+
subject.consumer.options[:access_token_path].should eq('/oauth')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'has correct authorize url' do
|
36
|
+
subject.consumer.options[:authorize_path].should eq('/OAuth.action')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#uid" do
|
41
|
+
before do
|
42
|
+
subject.stub(:raw_info) do
|
43
|
+
OpenStruct.new('id' => '123')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'returns the id from raw_info' do
|
48
|
+
subject.uid.should eq('123')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#info" do
|
53
|
+
before :each do
|
54
|
+
subject.stub(:raw_info) do
|
55
|
+
OpenStruct.new(:name => "Mike Rotch", :username => "mikerotch")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'returns the name from raw_info' do
|
60
|
+
subject.info['name'].should eq('Mike Rotch')
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'returns the username from raw_info as nickname' do
|
64
|
+
subject.info['nickname'].should eq('mikerotch')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "#extra" do
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "#raw_info" do
|
72
|
+
end
|
73
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-evernote
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Szymon Nowak
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-14 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-oauth
|
16
|
+
requirement: &2155428160 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2155428160
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: evernote
|
27
|
+
requirement: &2155427660 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.1.0
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2155427660
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: multi_json
|
38
|
+
requirement: &2155427200 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.0.4
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2155427200
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: &2155426720 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.7'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2155426720
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rake
|
60
|
+
requirement: &2155426320 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2155426320
|
69
|
+
description: OmniAuth strategy for Evernote
|
70
|
+
email:
|
71
|
+
- szimek@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .travis.yml
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/omniauth-evernote.rb
|
83
|
+
- lib/omniauth-evernote/version.rb
|
84
|
+
- lib/omniauth/strategies/evernote.rb
|
85
|
+
- omniauth-evernote.gemspec
|
86
|
+
- spec/omniauth/strategies/evernote_spec.rb
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
homepage: https://github.com/szimek/omniauth-evernote
|
89
|
+
licenses: []
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 1.8.10
|
109
|
+
signing_key:
|
110
|
+
specification_version: 3
|
111
|
+
summary: OmniAuth strategy for Evernote
|
112
|
+
test_files:
|
113
|
+
- spec/omniauth/strategies/evernote_spec.rb
|
114
|
+
- spec/spec_helper.rb
|