omniauth-googleplus 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,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MjMzNzlmZDM4ZWVkNmNlMTcyNWYxZTY2NzliMjVjZDJlOTI2ODczMg==
5
+ data.tar.gz: !binary |-
6
+ ZTc0OTY0MzliMjgwZDk0OWI2NDcwYmVlMWFkZDg0MjFiNjk5OGYyYw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MmExNDFkYzIxMzEzMzZkYWMyYTJmYmQ2Mjk1MGE0NDk0ZGY1YzMzNzBkNDE3
10
+ M2E2MTkyZDAxYTczNjMwMmI2OWMwYzYyZTdmZjM4YmI3YTMyZjc5OGMxZDcy
11
+ ZjYyNjg1MmEwMGU2ZmM0Njc2NTQzNjU1ZjNiODQ3MDhiN2ViN2Q=
12
+ data.tar.gz: !binary |-
13
+ ZDk2MmIzZGEwYmE1M2ViZTBkN2FkMGZmZDk5ZjZiNjk3NGQ1YmY3NWQxMTU3
14
+ YWM5YjA2OGE2Y2ZiY2NiMjRiMDlmMDcyZTc2NmI0OWMzMmJhNTYwZjExMTU2
15
+ MzA4ODJjZGIwYzUxY2MzNTFiNWQzNWVjOGJmNjFiMWE1ZjNkNjc=
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ coverage
6
+ *.rbc
7
+ *.sassc
8
+ .sass-cache
9
+ capybara-*.html
10
+ .rspec
11
+ /.bundle
12
+ /vendor/bundle
13
+ /log/*
14
+ /tmp/*
15
+ /db/*.sqlite3
16
+ /public/system/*
17
+ /coverage/
18
+ /spec/tmp/*
19
+ **.orig
20
+ rerun.txt
21
+ pickle-email-*.html
22
+ .redcar/*
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - ruby-head
6
+ - ree
7
+
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rake'
4
+ # Specify your gem's dependencies in omniauth-googleplus.gemspec
5
+ gemspec
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # OmniAuth Google+
2
+
3
+ This gem contains the Google+ strategy for OmniAuth.
4
+
5
+ Google+ uses the OAuth 2 flow, you can read about it here: https://developers.google.com/+/web/signin/
6
+
7
+ ## How To Use It
8
+
9
+ Like other OmniAuth 1.0 strategies. If you are using Rails, you need to add this to your `Gemfile`:
10
+
11
+ gem "omniauth", ">= 1.0.0"
12
+ gem 'omniauth-googleplus', :git => 'https://github.com/tasboa/omniauth-googleplus.git'
13
+
14
+ Then add the following to your `config/initializers/omniauth.rb` (or just the provider line if you have others already):
15
+
16
+ Rails.application.config.middleware.use OmniAuth::Builder do
17
+ provider :googleplus, "consumer_key", "consumer_secret"
18
+ end
19
+
20
+ REMEMBER to replace with your real key and secret, which you get when you register your app with Google+
21
+
22
+ Now just follow the README at: https://github.com/intridea/omniauth
23
+
24
+ ## Supported Rubies
25
+
26
+ OmniAuth Google+ is tested under 1.9.3
27
+
28
+ ## License
29
+
30
+ Copyright (c) 2013 by Nicholas Roberts
31
+
32
+ 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:
33
+
34
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
35
+
36
+ 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,11 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc 'Default: run specs.'
5
+ task :default => :spec
6
+
7
+ desc "Run specs"
8
+ RSpec::Core::RakeTask.new
9
+
10
+ desc 'Run specs'
11
+ task :default => :spec
@@ -0,0 +1,2 @@
1
+ require "omniauth-googleplus/version"
2
+ require 'omniauth/strategies/googleplus'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module GooglePlus
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,86 @@
1
+ require 'omniauth/strategies/oauth2'
2
+ require 'base64'
3
+ require 'openssl'
4
+ require 'rack/utils'
5
+
6
+ module OmniAuth
7
+ module Strategies
8
+ class GooglePlus < OmniAuth::Strategies::OAuth2
9
+ class NoAuthorizationCodeError < StandardError; end
10
+
11
+ option :name, 'googleplus'
12
+ option :authorize_options, [:scope, :approval_prompt, :access_type, :state, :hd]
13
+
14
+ option :client_options, {
15
+ :site => 'https://accounts.google.com',
16
+ :authorize_url => '/o/oauth2/auth',
17
+ :token_url => '/o/oauth2/token'
18
+ }
19
+
20
+ #https://accounts.google.com/o/oauth2/auth?
21
+ #scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile&
22
+ #state=%2Fprofile&
23
+ #redirect_uri=https%3A%2F%2Foauth2-login-demo.appspot.com%2Foauthcallback&
24
+ #response_type=token&
25
+ #client_id=812741506391.apps.googleusercontent.com
26
+
27
+ def authorize_params
28
+ base_scope_url = "https://www.googleapis.com/auth/"
29
+ super.tap do |params|
30
+ # Read the params if passed directly to omniauth_authorize_path
31
+ %w(scope approval_prompt access_type state hd).each do |k|
32
+ params[k.to_sym] = request.params[k] unless [nil, ''].include?(request.params[k])
33
+ end
34
+ scopes = (params[:scope] || DEFAULT_SCOPE).split(",")
35
+ scopes.map! { |s| s =~ /^https?:\/\// ? s : "#{base_scope_url}#{s}" }
36
+ params[:scope] = scopes.join(' ')
37
+ # This makes sure we get a refresh_token.
38
+ # http://googlecode.blogspot.com/2011/10/upcoming-changes-to-oauth-20-endpoint.html
39
+ params[:access_type] = 'offline' if params[:access_type].nil?
40
+ params[:approval_prompt] = 'force' if params[:approval_prompt].nil?
41
+ # Override the state per request
42
+ session['omniauth.state'] = params[:state] if request.params['state']
43
+ end
44
+ end
45
+
46
+ uid{ raw_info['id'] || verified_email }
47
+
48
+ info do
49
+ prune!({
50
+ :name => raw_info['name'],
51
+ :email => verified_email,
52
+ :first_name => raw_info['given_name'],
53
+ :last_name => raw_info['family_name'],
54
+ :image => raw_info['picture'],
55
+ :urls => {
56
+ 'Google' => raw_info['link']
57
+ }
58
+ })
59
+ end
60
+
61
+ extra do
62
+ hash = {}
63
+ hash[:raw_info] = raw_info unless skip_info?
64
+ prune! hash
65
+ end
66
+
67
+ def raw_info
68
+ @raw_info ||= access_token.get('https://www.googleapis.com/oauth2/v1/userinfo').parsed
69
+ end
70
+
71
+ private
72
+
73
+ def prune!(hash)
74
+ hash.delete_if do |_, value|
75
+ prune!(value) if value.is_a?(Hash)
76
+ value.nil? || (value.respond_to?(:empty?) && value.empty?)
77
+ end
78
+ end
79
+
80
+ def verified_email
81
+ raw_info['verified_email'] ? raw_info['email'] : nil
82
+ end
83
+
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-googleplus/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-googleplus"
7
+ s.version = Omniauth::GooglePlus::VERSION
8
+ s.authors = ["Niko Roberts"]
9
+ s.email = ["niko@tasboa.com"]
10
+ s.homepage = "https://github.com/tasboa/omniauth-googleplus"
11
+ s.summary = %q{OmniAuth strategy for Google Plus}
12
+ s.description = %q{OmniAuth strategy for Google Plus}
13
+
14
+ s.rubyforge_project = "omniauth-googleplus"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_runtime_dependency 'omniauth-oauth', '~> 1.0'
22
+ s.add_development_dependency 'rspec', '~> 2.7'
23
+ s.add_development_dependency 'rack-test'
24
+ s.add_development_dependency 'simplecov'
25
+ s.add_development_dependency 'webmock'
26
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::GooglePlus do
4
+ it 'should do some testing' do
5
+ pending
6
+ end
7
+ end
@@ -0,0 +1,16 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ require 'rspec'
6
+ require 'rack/test'
7
+ require 'webmock/rspec'
8
+ require 'omniauth'
9
+ require 'omniauth-googleplus'
10
+
11
+ RSpec.configure do |config|
12
+ config.include WebMock::API
13
+ config.include Rack::Test::Methods
14
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
15
+ end
16
+
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-googleplus
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Niko Roberts
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-02-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '2.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '2.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rack-test
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: OmniAuth strategy for Google Plus
84
+ email:
85
+ - niko@tasboa.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .rspec
92
+ - .travis.yml
93
+ - Gemfile
94
+ - README.md
95
+ - Rakefile
96
+ - lib/omniauth-googleplus.rb
97
+ - lib/omniauth-googleplus/version.rb
98
+ - lib/omniauth/strategies/googleplus.rb
99
+ - omniauth-googleplus.gemspec
100
+ - spec/omniauth/strategies/googleplus_spec.rb
101
+ - spec/spec_helper.rb
102
+ homepage: https://github.com/tasboa/omniauth-googleplus
103
+ licenses: []
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project: omniauth-googleplus
121
+ rubygems_version: 2.0.0
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: OmniAuth strategy for Google Plus
125
+ test_files:
126
+ - spec/omniauth/strategies/googleplus_spec.rb
127
+ - spec/spec_helper.rb