omniauth-todoist 0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a28c2748a9c177e18535b1f6d0bb9ac24bb9e1f3
4
+ data.tar.gz: 60f483432bcc23385678fa12bf3ed93ecb4ff2e5
5
+ SHA512:
6
+ metadata.gz: 2f0c31e36381ca4f8e19b46f296a501c6123050c1e905e5d5543137f897ec498011e8281f44a72134d9fefa3574c57eeafb14623941ac20b95776175b7e37616
7
+ data.tar.gz: 7e9f6ae1a52826292c3558dc07d62d3182ca0f012951e214eca13b623e4f6c994cef1e8a02a9b32b8a3255616b6499052e81eab4b7e2126255f5dc98c09b01ab
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Beeminder
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # OmniAuth Todoist
2
+ An OmniAuth strategy for authenticating to [Todoist](https://todoist.com/). To use it you'll need to register an application with [Todoist](https://developer.todoist.com/appconsole.html) to get an OAuth2 Client ID and Secret. More info on what and how you can use Todoist's API can we found [in their api docs](https://developer.todoist.com/).
3
+
4
+ ## Basic Usage
5
+
6
+ ```
7
+ use OmniAuth::Builder do
8
+ provider :todoist, ENV['TODOIST_CLIENT_ID'], ENV['TODOIST_CLIENT_SECRET']
9
+ end
10
+ ```
11
+
12
+ ## Copyright
13
+
14
+ Copyright (c) 2013 Beeminder inc. See LICENSE.txt for further details.
@@ -0,0 +1,68 @@
1
+ require 'omniauth-oauth2'
2
+ require 'multi_json'
3
+
4
+
5
+ module OmniAuth
6
+ module Strategies
7
+ class Todoist < OmniAuth::Strategies::OAuth2
8
+ DEFAULT_SCOPE = 'data:read'
9
+
10
+ # Give your strategy a name.
11
+ option :name, "todoist"
12
+
13
+ # This is where you pass the options you would pass when
14
+ # initializing your consumer from the OAuth gem.
15
+ option :client_options, {
16
+ :site => "https://todoist.com",
17
+ :authorize_url => "/oauth/authorize",
18
+ :token_url => "/oauth/access_token"
19
+ }
20
+
21
+ # These are called after authentication has succeeded. If
22
+ # possible, you should try to set the UID without making
23
+ # additional calls (if the user id is returned with the token
24
+ # or as a URI parameter). This may not be possible with all
25
+ # providers.
26
+ uid{ raw_info['id'] }
27
+
28
+ info do
29
+ { :email => raw_info["email"] }
30
+ end
31
+
32
+ def request_phase
33
+ super
34
+ end
35
+
36
+ def callback_phase
37
+ super
38
+ end
39
+
40
+ # Bugfix for regression introduced after omniauth-oauth2 v1.3.1
41
+ # details: https://github.com/intridea/omniauth-oauth2/issues/81
42
+ def callback_url
43
+ options[:callback_url] || full_host + script_name + callback_path
44
+ end
45
+
46
+ def raw_info
47
+ unless @raw_info
48
+ user_info = access_token.post("/API/v7/sync", {
49
+ body: {
50
+ token: access_token.token,
51
+ sync_token: "*",
52
+ resource_types: '["user"]' },
53
+ headers: {
54
+ "Content-Type"=>"application/x-www-form-urlencoded" }
55
+ }).parsed
56
+ if user_info["user"]
57
+ @raw_info = user_info["user"]
58
+ else
59
+ @raw_info = {}
60
+ end
61
+ end
62
+ @raw_info
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+
@@ -0,0 +1 @@
1
+ require 'omniauth/strategies/todoist'
@@ -0,0 +1,15 @@
1
+ Gem::Specification.new do |gem|
2
+ gem.name = 'omniauth-todoist'
3
+ gem.version = '0.1'
4
+ gem.date = Date.today.to_s
5
+ gem.license = 'MIT'
6
+ gem.summary = "OmniAuth strategy for Todoist"
7
+ gem.description = "OmniAuth strategy for Todoist"
8
+
9
+ gem.authors = ['Bethany Soule']
10
+ gem.email = 'bsoule@beeminder.com'
11
+ gem.homepage = 'https://github.com/beeminder/omniauth-todoist'
12
+
13
+ gem.files = `git ls-files`.split("\n")
14
+ gem.require_path = 'lib'
15
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-todoist
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Bethany Soule
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-16 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: OmniAuth strategy for Todoist
14
+ email: bsoule@beeminder.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - Gemfile
20
+ - LICENSE.txt
21
+ - README.md
22
+ - lib/omniauth-todoist.rb
23
+ - lib/omniauth/strategies/todoist.rb
24
+ - omniauth-todoist.gemspec
25
+ homepage: https://github.com/beeminder/omniauth-todoist
26
+ licenses:
27
+ - MIT
28
+ metadata: {}
29
+ post_install_message:
30
+ rdoc_options: []
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ requirements: []
44
+ rubyforge_project:
45
+ rubygems_version: 2.4.5
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: OmniAuth strategy for Todoist
49
+ test_files: []