omniauth-pinterest-oauth2 0.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
+ SHA256:
3
+ metadata.gz: '09537e33b940575cdfe726deec41d4a05c5196d483b2edd4aaca6a150be706d3'
4
+ data.tar.gz: ba00974535eb34604e74bd79cb72e2d64f38632fdfa1ed130726a129e002feba
5
+ SHA512:
6
+ metadata.gz: 6c7ed9a4fc059fef50f7a72492ade253a50924de7fa35c8af31208977469c41590b4fc7e615459c6aa7c61bdb6c3453ad55c58f1916eff8344a5b08826f96af9
7
+ data.tar.gz: d9111218d4199d0aed7060a327e26625dfa5904e5f69a34ccb55ced00bcedd606402e78c269388cb4f9d5e77f4e6325d2ea4ff27251353540f9b425f235d4144
data/.gitignore ADDED
@@ -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
data/Gemfile.lock ADDED
@@ -0,0 +1,144 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-pinterest-oauth2 (0.0.1)
5
+ omniauth-oauth2
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ base64 (0.2.0)
11
+ bigdecimal (3.1.9)
12
+ coderay (1.1.3)
13
+ diff-lcs (1.6.1)
14
+ faraday (2.13.1)
15
+ faraday-net_http (>= 2.0, < 3.5)
16
+ json
17
+ logger
18
+ faraday-net_http (3.4.0)
19
+ net-http (>= 0.5.0)
20
+ ffi (1.17.2)
21
+ ffi (1.17.2-aarch64-linux-gnu)
22
+ ffi (1.17.2-aarch64-linux-musl)
23
+ ffi (1.17.2-arm-linux-gnu)
24
+ ffi (1.17.2-arm-linux-musl)
25
+ ffi (1.17.2-arm64-darwin)
26
+ ffi (1.17.2-x86-linux-gnu)
27
+ ffi (1.17.2-x86-linux-musl)
28
+ ffi (1.17.2-x86_64-darwin)
29
+ ffi (1.17.2-x86_64-linux-gnu)
30
+ ffi (1.17.2-x86_64-linux-musl)
31
+ formatador (1.1.0)
32
+ growl (1.0.3)
33
+ guard (2.19.1)
34
+ formatador (>= 0.2.4)
35
+ listen (>= 2.7, < 4.0)
36
+ logger (~> 1.6)
37
+ lumberjack (>= 1.0.12, < 2.0)
38
+ nenv (~> 0.1)
39
+ notiffany (~> 0.0)
40
+ ostruct (~> 0.6)
41
+ pry (>= 0.13.0)
42
+ shellany (~> 0.0)
43
+ thor (>= 0.18.1)
44
+ guard-bundler (3.0.1)
45
+ bundler (>= 2.1, < 3)
46
+ guard (~> 2.2)
47
+ guard-compat (~> 1.1)
48
+ guard-compat (1.2.1)
49
+ guard-rspec (4.7.3)
50
+ guard (~> 2.1)
51
+ guard-compat (~> 1.1)
52
+ rspec (>= 2.99.0, < 4.0)
53
+ hashie (5.0.0)
54
+ json (2.11.3)
55
+ jwt (2.10.1)
56
+ base64
57
+ listen (3.9.0)
58
+ rb-fsevent (~> 0.10, >= 0.10.3)
59
+ rb-inotify (~> 0.9, >= 0.9.10)
60
+ logger (1.7.0)
61
+ lumberjack (1.2.10)
62
+ method_source (1.1.0)
63
+ multi_xml (0.7.2)
64
+ bigdecimal (~> 3.1)
65
+ nenv (0.3.0)
66
+ net-http (0.6.0)
67
+ uri
68
+ notiffany (0.1.3)
69
+ nenv (~> 0.1)
70
+ shellany (~> 0.0)
71
+ oauth2 (2.0.9)
72
+ faraday (>= 0.17.3, < 3.0)
73
+ jwt (>= 1.0, < 3.0)
74
+ multi_xml (~> 0.5)
75
+ rack (>= 1.2, < 4)
76
+ snaky_hash (~> 2.0)
77
+ version_gem (~> 1.1)
78
+ omniauth (2.1.3)
79
+ hashie (>= 3.4.6)
80
+ rack (>= 2.2.3)
81
+ rack-protection
82
+ omniauth-oauth2 (1.8.0)
83
+ oauth2 (>= 1.4, < 3)
84
+ omniauth (~> 2.0)
85
+ ostruct (0.6.1)
86
+ pry (0.15.2)
87
+ coderay (~> 1.1)
88
+ method_source (~> 1.0)
89
+ rack (3.1.14)
90
+ rack-protection (4.1.1)
91
+ base64 (>= 0.1.0)
92
+ logger (>= 1.6.0)
93
+ rack (>= 3.0.0, < 4)
94
+ rake (13.2.1)
95
+ rb-fsevent (0.11.2)
96
+ rb-inotify (0.11.1)
97
+ ffi (~> 1.0)
98
+ rspec (3.13.0)
99
+ rspec-core (~> 3.13.0)
100
+ rspec-expectations (~> 3.13.0)
101
+ rspec-mocks (~> 3.13.0)
102
+ rspec-core (3.13.3)
103
+ rspec-support (~> 3.13.0)
104
+ rspec-expectations (3.13.4)
105
+ diff-lcs (>= 1.2.0, < 2.0)
106
+ rspec-support (~> 3.13.0)
107
+ rspec-mocks (3.13.4)
108
+ diff-lcs (>= 1.2.0, < 2.0)
109
+ rspec-support (~> 3.13.0)
110
+ rspec-support (3.13.3)
111
+ shellany (0.0.1)
112
+ snaky_hash (2.0.1)
113
+ hashie
114
+ version_gem (~> 1.1, >= 1.1.1)
115
+ thor (1.3.2)
116
+ uri (1.0.3)
117
+ version_gem (1.1.8)
118
+
119
+ PLATFORMS
120
+ aarch64-linux-gnu
121
+ aarch64-linux-musl
122
+ arm-linux-gnu
123
+ arm-linux-musl
124
+ arm64-darwin
125
+ ruby
126
+ x86-linux-gnu
127
+ x86-linux-musl
128
+ x86_64-darwin
129
+ x86_64-linux-gnu
130
+ x86_64-linux-musl
131
+
132
+ DEPENDENCIES
133
+ bundler
134
+ growl
135
+ guard
136
+ guard-bundler
137
+ guard-rspec
138
+ omniauth-pinterest-oauth2!
139
+ rake
140
+ rb-fsevent
141
+ rspec
142
+
143
+ BUNDLED WITH
144
+ 2.5.17
data/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ ## The MIT License
2
+
3
+ Copyright (c) 2025 Astro Pump.
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.
data/README.md ADDED
@@ -0,0 +1,62 @@
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-pinterest-oauth2'
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,
26
+ ENV['PINTEREST_APP_ID'],
27
+ ENV['PINTEREST_APP_SECRET'],
28
+ scope: 'user_accounts:read, pins:read',
29
+ redirect_uri: 'https://mysite.com/auth/pinterest/callback'
30
+ end
31
+ ```
32
+
33
+ After restarting your application, point the authenticating user to `/auth/pinterest`, the rest will be handled by OmniAuth.
34
+
35
+ ## Authentication hash
36
+
37
+ Here's an example authentication hash available in `request.env['omniauth.auth']`:
38
+
39
+ ```ruby
40
+ {
41
+ provider: 'pinterest',
42
+ uid: '1234',
43
+ info: {
44
+ id: '1234',
45
+ url: 'https://www.pinterest.com/jane_doe/',
46
+ first_name: 'Jane',
47
+ last_name: 'Doe',
48
+ },
49
+ }
50
+ ```
51
+
52
+ ## License
53
+
54
+ (The MIT License)
55
+
56
+ Copyright (c) 2025 Astro Pump.
57
+
58
+ 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:
59
+
60
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
61
+
62
+ 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,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,69 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Pinterest < OmniAuth::Strategies::OAuth2
6
+ option :client_options,
7
+ {
8
+ site: 'https://api.pinterest.com/',
9
+ authorize_url: 'https://pinterest.com/oauth/',
10
+ token_url: 'https://api.pinterest.com/v5/oauth/token',
11
+ token_method: :post,
12
+ }
13
+
14
+ def request_phase
15
+ options[:scope] ||= 'user_accounts:read'
16
+ options[:response_type] ||= 'code'
17
+ super
18
+ end
19
+
20
+ uid { raw_info['id'] }
21
+
22
+ info { raw_info }
23
+
24
+ def raw_info
25
+ access_token.options[:parse] = :json
26
+ @raw_info ||= access_token.get('/v5/user_account').parsed
27
+ end
28
+
29
+ def ssl?
30
+ true
31
+ end
32
+
33
+ # You can pass +display+, +scope+, or +auth_type+ params to the auth request, if you need to set them dynamically.
34
+ # You can also set these options in the OmniAuth config :authorize_params option.
35
+ #
36
+ # For example: /auth/pinterest?display=popup
37
+ def authorize_params
38
+ super.tap do |params|
39
+ %w[display scope auth_type].each do |v|
40
+ params[v.to_sym] = request.params[v] if request.params[v]
41
+ end
42
+
43
+ params[:scope] ||= DEFAULT_SCOPE
44
+ end
45
+ end
46
+
47
+ def build_access_token
48
+ options.token_params.merge!(
49
+ headers: {
50
+ 'Authorization' => basic_auth_header,
51
+ },
52
+ )
53
+ super
54
+ end
55
+
56
+ def basic_auth_header
57
+ auth =
58
+ Base64.strict_encode64(
59
+ "#{options[:client_id]}:#{options[:client_secret]}",
60
+ )
61
+ "Basic #{auth}"
62
+ end
63
+
64
+ def callback_url
65
+ full_host + script_name + callback_path
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Pinterest
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require 'omniauth-pinterest-oauth2/version'
2
+ require 'omniauth/strategies/pinterest'
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-pinterest-oauth2/version', __FILE__)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.authors = ['Astro Pump']
6
+ spec.email = ['support@astropump.fun']
7
+
8
+ spec.summary = 'Pinterest OAuth2 Strategy for OmniAuth'
9
+ spec.homepage = 'https://github.com/astropump-fun/omniauth-pinterest-oauth2'
10
+ spec.license = 'MIT'
11
+
12
+ spec.executables =
13
+ `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-pinterest-oauth2'
17
+ spec.require_paths = ['lib']
18
+ spec.version = '0.0.1'
19
+
20
+ spec.add_dependency 'omniauth-oauth2'
21
+
22
+ spec.add_development_dependency 'bundler'
23
+ spec.add_development_dependency 'rake'
24
+ spec.add_development_dependency 'rspec'
25
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Pinterest do
4
+ context 'client options' do
5
+ subject { OmniAuth::Strategies::Pinterest.new({}) }
6
+
7
+ it 'should have correct site' do
8
+ subject.options.client_options.site.should eq(
9
+ 'https://api.pinterest.com/',
10
+ )
11
+ end
12
+
13
+ it 'should have correct authorize url' do
14
+ subject.options.client_options.authorize_url.should eq(
15
+ 'https://pinterest.com/oauth/',
16
+ )
17
+ end
18
+
19
+ it 'should have correct token url' do
20
+ subject.options.client_options.token_url.should eq(
21
+ 'https://api.pinterest.com/v5/oauth/token',
22
+ )
23
+ end
24
+ end
25
+ 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-pinterest-oauth2'
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-pinterest-oauth2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Astro Pump
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-05-11 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
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
+ - !ruby/object:Gem::Dependency
42
+ name: rake
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: rspec
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
+ description:
70
+ email:
71
+ - support@astropump.fun
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - Gemfile.lock
79
+ - LICENSE.md
80
+ - README.md
81
+ - Rakefile
82
+ - lib/omniauth-pinterest-oauth2.rb
83
+ - lib/omniauth-pinterest-oauth2/version.rb
84
+ - lib/omniauth/strategies/pinterest.rb
85
+ - omniauth-pinterest-oauth2.gemspec
86
+ - spec/omniauth/strategies/pinterest_spec.rb
87
+ - spec/spec_helper.rb
88
+ homepage: https://github.com/astropump-fun/omniauth-pinterest-oauth2
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubygems_version: 3.4.1
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