omniauth-zoho 0.2.0

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: ca4edc3d11c121c1a4015620322846cb4a8d0e9f
4
+ data.tar.gz: c48d7aa2cfa03a789f29f59d927ad2ff82bdc19a
5
+ SHA512:
6
+ metadata.gz: 140d362ad6e81960c68a70638fe9986fa2a419453b90392356cf88ab12ee9817e12bce2ad40fe9b2eb3c263e848a8841f1cf75a836f6a434e307939c6f5424fb
7
+ data.tar.gz: 40e5c9b768764a5920d1a02578f11b1ad02d35e1959e44aaab280e053458b192599260f1a9c9b7629be45358ee8b0b8b778ff684d428b96debe11b1e6e991c57
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /.idea
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+
2
+ # OmniAuth Zoho
3
+
4
+ Zoho OAuth2 Strategy for OmniAuth 1.0 to access Zoho services such as ZohoCRM.
5
+
6
+ ## Installing
7
+
8
+ Add to your `Gemfile`:
9
+
10
+ ```ruby
11
+ gem 'omniauth-zoho'
12
+ ```
13
+
14
+ Then `bundle install`.
15
+
16
+ ## Usage
17
+
18
+ `OmniAuth::Strategies::Zoho` is simply a Rack middleware. Read [the OmniAuth 1.0 docs](https://github.com/intridea/omniauth) for detailed instructions.
19
+
20
+ Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
21
+
22
+ ```ruby
23
+ Rails.application.config.middleware.use OmniAuth::Builder do
24
+ provider :zoho, ENV['ZOHO_API_KEY'], ENV['ZOHO_SHARED_SECRET'], scope: 'ZohoCRM.modules.ALL'
25
+ end
26
+ ```
27
+
28
+ ## Authentication Hash
29
+
30
+ Here's an example *Authentication Hash* available in `request.env['omniauth.auth']`:
31
+
32
+ ```ruby
33
+ {
34
+ :provider => 'zoho',
35
+ :uid => '1234',
36
+ :credentials => {
37
+ :token => 'afasd923kjh0934kf', # OAuth 2.0 access_token, which you store and use to authenticate API requests
38
+ }
39
+ }
40
+ ```
41
+
42
+ ## License
43
+
44
+ Copyright (c) 2016 by LeadDyno, LLC
45
+
46
+ 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:
47
+
48
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
49
+
50
+ 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.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :spec
@@ -0,0 +1,46 @@
1
+ require 'omniauth/strategies/oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Zoho < OmniAuth::Strategies::OAuth2
6
+
7
+ option :client_options, {
8
+ :site => 'https://accounts.zoho.com',
9
+ :authorize_url => '/oauth/v2/auth',
10
+ :token_url => '/oauth/v2/token'
11
+ }
12
+
13
+ option provider_ignores_state: true
14
+
15
+ uid{ raw_info['id'] }
16
+
17
+ info do
18
+ {
19
+ :email => raw_info['primary_email'],
20
+ }
21
+ end
22
+
23
+ extra do
24
+ {
25
+ 'raw_info' => raw_info
26
+ }
27
+ end
28
+
29
+ credentials do
30
+ hash = {"token" => access_token.token}
31
+ hash.merge!("refresh_token" => access_token.refresh_token) if access_token.refresh_token
32
+ hash.merge!("expires_at" => Time.now.to_i + access_token.params['expires_in_sec'].to_i) if access_token.params['expires_in_sec']
33
+ hash.merge!("expires" => access_token.expires?)
34
+ hash
35
+ end
36
+
37
+ def raw_info
38
+ @raw_info ||= access_token.get('https://www.zohoapis.com/crm/v2/org').parsed['org'].first
39
+ end
40
+
41
+ def callback_url
42
+ full_host + script_name + callback_path
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Zoho
3
+ VERSION = "0.2.0"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require 'omniauth/zoho/version'
2
+ require 'omniauth/strategies/zoho'
@@ -0,0 +1 @@
1
+ require 'omniauth/zoho'
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth/zoho/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-zoho"
8
+ spec.version = OmniAuth::Zoho::VERSION
9
+ spec.authors = ["Mike Machado"]
10
+ spec.email = ["mike@leaddyno.com"]
11
+
12
+ spec.summary = %q{Zoho strategy for OmniAuth.}
13
+ spec.homepage = "https://github.com/LeadDyno/omniauth-zoho"
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.2'
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.11"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "minitest", "~> 5.0"
25
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-zoho
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Mike Machado
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-12-27 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.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.11'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ description:
70
+ email:
71
+ - mike@leaddyno.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - Gemfile
79
+ - README.md
80
+ - Rakefile
81
+ - lib/omniauth-zoho.rb
82
+ - lib/omniauth/strategies/zoho.rb
83
+ - lib/omniauth/zoho.rb
84
+ - lib/omniauth/zoho/version.rb
85
+ - omniauth-zoho.gemspec
86
+ homepage: https://github.com/LeadDyno/omniauth-zoho
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.6.14.1
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Zoho strategy for OmniAuth.
110
+ test_files: []