omniauth-dropbox-business-api2 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3239bbacedc442fca63b022a60021d25b9b5ea29
4
+ data.tar.gz: 08899e95db91e8a9603d45812a57b9481c0a7c6a
5
+ SHA512:
6
+ metadata.gz: b75e5d86ca100e3c26c22c4b76a4ca59b6868ee8f46da4a6b8b70741cc59e93da270abcae2389fd70bc48cd97fc22d69192a64ad2708ecf5c3663508f8d647e7
7
+ data.tar.gz: 156667cfa1337534ea796a1e69adee9b5c5414506da7b832a0ad85df3691c65029113161b9e111654df0dd646fab61e1c8aae2ec08eb63d87b5647f4ba6963cb
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ # Ignore application configuration
2
+ .idea
3
+ omniauth-dropbox-business-api2-*.*.*.gem
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ OmniAuth Dropbox Business API 2
2
+ =====================================
3
+
4
+ Strategy to authenticate Dropbox in OmniAuth using the business api v2.
5
+
6
+ It's using the OAuth2 from the [Dropbox API](https://www.dropbox.com/developers) Business EndPoint.
7
+
8
+ Usage
9
+ -----
10
+
11
+ Add the strategy to your `Gemfile` alongside OmniAuth:
12
+
13
+ ```ruby
14
+ gem 'omniauth'
15
+ gem 'omniauth-dropbox-business-api2'
16
+ ```
17
+
18
+ Integrate this strategy to your OmniAuth middleware.
19
+
20
+ ```ruby
21
+ use OmniAuth::Builder do
22
+ provider :dropbox_oauth2, ENV['DROPBOX_KEY'], ENV['DROPBOX_SECRET']
23
+ end
24
+ ```
25
+
26
+ You need to add your key and secret.
27
+
28
+ Also remember to add the full callback path to your Dropbox App Console, for example: https://example.com/auth/dropbox_oauth2/callback
29
+
30
+ For more information check the [OmniAuth wiki](https://github.com/intridea/omniauth/wiki).
31
+
32
+
33
+ Helping
34
+ -------
35
+
36
+ * Fork the project, make your changes and send me a pull request.
37
+ * Create an issue! :D
38
+
39
+ License
40
+ -------
41
+
42
+ Copyright (c) 2017 Nitanshu Verma
43
+
44
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
45
+
46
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
47
+
48
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ require File.join('omniauth', 'dropbox_oauth2')
@@ -0,0 +1 @@
1
+ require File.join('omniauth','strategies', 'dropbox_oauth2')
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module DropboxOauth2
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,52 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class DropboxOauth2 < OmniAuth::Strategies::OAuth2
6
+ option :name, "dropbox_oauth2"
7
+ option :client_options, {
8
+ :site => 'https://api.dropbox.com',
9
+ :authorize_url => 'https://www.dropbox.com/oauth2/authorize',
10
+ :token_url => 'https://api.dropbox.com/oauth2/token'
11
+ }
12
+
13
+ uid { raw_info['uid'] }
14
+
15
+ info do
16
+ {
17
+ 'uid' => raw_info['account_id'],
18
+ 'name' => raw_info['name']['display_name'],
19
+ 'email' => raw_info['email']
20
+ }
21
+ end
22
+
23
+ extra do
24
+ { 'raw_info' => raw_info }
25
+ end
26
+
27
+ def raw_info
28
+ conn = Faraday.new(:url => 'https://api.dropbox.com') do |faraday|
29
+ faraday.request :url_encoded # form-encode POST params
30
+ faraday.response :logger # log requests to STDOUT
31
+ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
32
+ end
33
+ response = conn.post do |req|
34
+ req.url '/2/team/get_info'
35
+ req.headers['Content-Type'] = 'application/json'
36
+ req.headers['Authorization'] = "Bearer #{access_token.token}"
37
+ req.body = "null"
38
+ end
39
+ @raw_info ||= MultiJson.decode(response.body)
40
+ # @raw_info ||= MultiJson.decode(access_token.get('/2/users/get_current_account').body)
41
+ end
42
+
43
+ def callback_url
44
+ if @authorization_code_from_signed_request
45
+ ''
46
+ else
47
+ options[:callback_url] || super
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+ require File.expand_path(File.join('..', 'lib', 'omniauth', 'dropbox_oauth2', 'version'), __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'omniauth-dropbox-business-api2'
6
+ gem.version = OmniAuth::DropboxOauth2::VERSION
7
+ gem.homepage = 'https://github.com/nitanshu/omniauth-dropbox-business-api2'
8
+
9
+ gem.author = 'Nitanshu Verma'
10
+ gem.email = 'nitanshu1991@gmail.com'
11
+ gem.description = 'Dropbox OAuth2 strategy for OmniAuth 1.x supporting business api v2'
12
+ gem.summary = gem.description
13
+
14
+ gem.add_dependency 'omniauth-oauth2', '~> 1.3.1'
15
+
16
+ gem.add_development_dependency 'rake'
17
+
18
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
19
+ gem.files = `git ls-files`.split("\n")
20
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+
22
+ gem.require_paths = ['lib']
23
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-dropbox-business-api2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nitanshu Verma
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-11-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.3.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.3.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Dropbox OAuth2 strategy for OmniAuth 1.x supporting business api v2
42
+ email: nitanshu1991@gmail.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - ".gitignore"
48
+ - Gemfile
49
+ - README.md
50
+ - lib/omniauth-dropbox-business-api2.rb
51
+ - lib/omniauth/dropbox_oauth2.rb
52
+ - lib/omniauth/dropbox_oauth2/version.rb
53
+ - lib/omniauth/strategies/dropbox_oauth2.rb
54
+ - omniauth-dropbox-business-api2.gemspec
55
+ homepage: https://github.com/nitanshu/omniauth-dropbox-business-api2
56
+ licenses: []
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.5.1
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Dropbox OAuth2 strategy for OmniAuth 1.x supporting business api v2
78
+ test_files: []