omniauth-pinterest2 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bfac99e340560a5542f5f9fca76385f371254ae3dca068dae3b9d05f30c8283b
4
+ data.tar.gz: 6c0e42420ef901b40422368bb79285c593d1d0828e52f6df1eeee1e89206f56e
5
+ SHA512:
6
+ metadata.gz: daa055674865fa5e40b2f15d038b4061c795b193daca320e695747d50c2d40180cfece3eec3e47a98ba32c3c7b8536b37482230ed80dc4988aed005f1a084857
7
+ data.tar.gz: 6746c233cdc6d46740686a708837a38799978139dcff69544cb3b342b0fd791c7704378a60acb4d3bb0ace718c550a99bac32964cbf096b62bb0c9a88a1c2313
@@ -0,0 +1,3 @@
1
+ coverage
2
+ *.gem
3
+ Guardfile
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-pinterest.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'guard'
8
+ gem 'guard-rspec'
9
+ gem 'guard-bundler'
10
+ gem 'growl'
11
+ gem 'rb-fsevent'
12
+ end
@@ -0,0 +1,9 @@
1
+ ## The MIT License
2
+
3
+ Copyright (c) 2018 Ugurcan Kaya, Pasilobus Inc.
4
+
5
+ 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:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ 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,58 @@
1
+ # OmniAuth Pinterest
2
+
3
+ This gem contains the [OmniAuth](https://github.com/intridea/omniauth/) strategy for authenticating to [Pinterest](https://www.pinterest.com/).
4
+
5
+ ## Preparation
6
+
7
+ 1. Register and sign into the [Pinterest developer center](https://developers.pinterest.com/)
8
+ 2. Create an [application](https://developers.pinterest.com/apps/) and note the **App ID** and the **App secret**
9
+ 3. Make sure that you have already installed [OmniAuth](https://github.com/intridea/omniauth/wiki) into your application. Otherwise check out the [installation details](https://github.com/intridea/omniauth) and the [documentation](https://github.com/intridea/omniauth/wiki).
10
+
11
+ ## Installation
12
+
13
+ Add this gem to your application's ```Gemfile```:
14
+
15
+ ```ruby
16
+ gem 'omniauth-pinterest2'
17
+ ```
18
+
19
+ Execute the ```bundle``` command to install the gem.
20
+
21
+ Next, tell OmniAuth about the Pinterest provider. For a Ruby on Rails application, your ```config/initializers/omniauth.rb``` file should look like:
22
+
23
+ ```ruby
24
+ Rails.application.config.middleware.use OmniAuth::Builder do
25
+ provider :pinterest, ENV['PINTEREST_APP_ID'], ENV['PINTEREST_APP_SECRET'], scope: 'read_public, write_public', redirect_uri: "https://mysite.com/auth/pinterest/callback"
26
+ end
27
+ ```
28
+
29
+ After restarting your application, point the authenticating user to ```/auth/pinterest```, the rest will be handled by OmniAuth.
30
+
31
+ ## Authentication hash
32
+
33
+ Here's an example authentication hash available in ```request.env['omniauth.auth']```:
34
+
35
+ ```ruby
36
+ {
37
+ :provider => 'pinterest',
38
+ :uid => '1234',
39
+ :info => {
40
+ :id => "1234",
41
+ :url => "https://www.pinterest.com/jane_doe/",
42
+ :first_name => "Jane",
43
+ :last_name => "Doe"
44
+ }
45
+ }
46
+ ```
47
+
48
+ ## License
49
+
50
+ (The MIT License)
51
+
52
+ Copyright (c) 2018 Ugurcan Kaya, Pasilobus Inc.
53
+
54
+ 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:
55
+
56
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
57
+
58
+ 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,9 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ desc 'Default: run specs.'
6
+ task :default => :spec
7
+
8
+ desc 'Run specs'
9
+ RSpec::Core::RakeTask.new
@@ -0,0 +1,2 @@
1
+ require 'omniauth-pinterest2/version'
2
+ require 'omniauth/strategies/pinterest'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Pinterest
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,53 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Pinterest < OmniAuth::Strategies::OAuth2
6
+ option :client_options, {
7
+ :site => 'https://api.pinterest.com/',
8
+ :authorize_url => 'https://api.pinterest.com/oauth/',
9
+ :token_url => 'https://api.pinterest.com/v1/oauth/token'
10
+ }
11
+
12
+ def request_phase
13
+ options[:scope] ||= 'read_public'
14
+ options[:response_type] ||= 'code'
15
+ super
16
+ end
17
+
18
+ uid { raw_info['id'] }
19
+
20
+ info { raw_info }
21
+
22
+ def raw_info
23
+ fields = 'first_name,id,last_name,url,account_type,username,bio,image'
24
+ @raw_info ||= access_token.get("/v1/me/?fields=#{fields}").parsed['data']
25
+ end
26
+
27
+ def ssl?
28
+ true
29
+ end
30
+
31
+ # You can pass +display+, +scope+, or +auth_type+ params to the auth request, if you need to set them dynamically.
32
+ # You can also set these options in the OmniAuth config :authorize_params option.
33
+ #
34
+ # For example: /auth/facebook?display=popup
35
+ def authorize_params
36
+ super.tap do |params|
37
+ %w[display scope auth_type].each do |v|
38
+ if request.params[v]
39
+ params[v.to_sym] = request.params[v]
40
+ end
41
+ end
42
+
43
+ params[:scope] ||= DEFAULT_SCOPE
44
+ end
45
+ end
46
+
47
+ def callback_url
48
+ full_host + script_name + callback_path
49
+ end
50
+
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-pinterest2/version', __FILE__)
3
+
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.authors = ["Ugurcan Kaya"]
7
+ spec.email = ["support@pasilobus.com"]
8
+
9
+ spec.summary = "Pinterest OAuth2 Strategy for OmniAuth"
10
+ spec.homepage = "https://github.com/uurcankaya/omniauth-pinterest2"
11
+ spec.license = "MIT"
12
+
13
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
14
+ spec.files = `git ls-files`.split("\n")
15
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ spec.name = "omniauth-pinterest2"
17
+ spec.require_paths = ["lib"]
18
+ spec.version = '0.1.0'
19
+
20
+ spec.add_dependency "omniauth-oauth2", '~> 1.5'
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.16"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Pinterest do
4
+
5
+ context 'client options' do
6
+ subject do
7
+ OmniAuth::Strategies::Pinterest.new({})
8
+ end
9
+
10
+ it 'should have correct site' do
11
+ subject.options.client_options.site.should eq('https://api.pinterest.com/')
12
+ end
13
+
14
+ it 'should have correct authorize url' do
15
+ subject.options.client_options.authorize_url.should eq('https://api.pinterest.com/oauth/')
16
+ end
17
+
18
+ it 'should have correct token url' do
19
+ subject.options.client_options.token_url.should eq('https://api.pinterest.com/v1/oauth/token')
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,15 @@
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-pinterest2'
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
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-pinterest2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ugurcan Kaya
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-08-19 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.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
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.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
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: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description:
70
+ email:
71
+ - support@pasilobus.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.md
79
+ - README.md
80
+ - Rakefile
81
+ - lib/omniauth-pinterest2.rb
82
+ - lib/omniauth-pinterest2/version.rb
83
+ - lib/omniauth/strategies/pinterest.rb
84
+ - omniauth-pinterest2.gemspec
85
+ - spec/omniauth/strategies/pinterest_spec.rb
86
+ - spec/spec_helper.rb
87
+ homepage: https://github.com/uurcankaya/omniauth-pinterest2
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.7.6
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Pinterest OAuth2 Strategy for OmniAuth
111
+ test_files:
112
+ - spec/omniauth/strategies/pinterest_spec.rb
113
+ - spec/spec_helper.rb