omniauth-pocket-oauth2 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 95354b9d6e44f88739bc7ee5a1eb0eacd62f816155a401214574bf5c59d62c2a
4
+ data.tar.gz: 68131f704eb902f84df7dd6ea85136df44604955a6a1b22ed79c76cc51a47e91
5
+ SHA512:
6
+ metadata.gz: '0283f4bcabe244010d22fb4fc7864c26d40d0b226b1b9c4b2c469e4a8490d18ff3cbd812199d124b8e3fe86ff8bd8a533a730cedccbe1f94d7d2320df4300e2d'
7
+ data.tar.gz: 8ea392c66330e15611686d926050935e813c78df9d53a02439364de2108bf70b25be39eed78b13fe55c037dbf44f1fcd9de59f4f9e1eeba106d61895055616ab
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Greg Leppert
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # OmniAuth::Pocket OAuth 2
2
+
3
+ An OmniAuth Strategy for getpocket.com.
4
+
5
+ This is based on [omniauth-pocket](https://github.com/leppert/omniauth-pocket)
6
+ but updated for OAuth 2.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'omniauth-pocket-oauth2'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install omniauth-pocket-oauth2
21
+
22
+ ## Setup
23
+
24
+ add provider to omniauth, like in devise.rb, use consumer key for `client_id`:
25
+ ```
26
+ config.omniauth :pocket, client_id: Rails.application.secrets.pocket_consumer_key
27
+ ````
28
+
29
+ Add/Create an omniauth callback controller to handle a `pocket` action.
30
+ ```
31
+ class Users::PocketCallbackController < Devise::OmniauthCallbacksController
32
+ def pocket
33
+ # do user stuff from response
34
+ end
35
+ end
36
+ ```
37
+
38
+
39
+ Add to routes
40
+ ```
41
+ devise_for :users, controllers: { omniauth_callbacks: "users/pocket_callback" }
42
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ require "omniauth-pocket-oauth2/version"
2
+ require "omniauth/strategies/pocket"
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Pocket
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth-pocket-oauth2/version"
2
+ require "omniauth/strategies/pocket"
@@ -0,0 +1,52 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Pocket < OmniAuth::Strategies::OAuth2
6
+ option :name, 'pocket'
7
+
8
+ option :provider_ignores_state, true
9
+
10
+ option :client_options, {
11
+ :site => 'https://getpocket.com',
12
+ :request_url => '/v3/oauth/request',
13
+ :authorize_url => '/auth/authorize',
14
+ :token_url => '/v3/oauth/authorize'
15
+ }
16
+
17
+ uid { raw_info['username'] }
18
+
19
+ info do
20
+ {
21
+ :name => raw_info['username'],
22
+ :nickname => raw_info['username']
23
+ }
24
+ end
25
+
26
+ extra do
27
+ { :raw_info => raw_info }
28
+ end
29
+
30
+ def raw_info
31
+ access_token.params
32
+ end
33
+
34
+ def request_phase
35
+ redirect client.authorize_url({:request_token => build_request_token, :redirect_uri => callback_url})
36
+ end
37
+
38
+ def build_request_token
39
+ response = client.request(:post, client.options[:request_url], {
40
+ :headers => {'Content-Type' => 'application/x-www-form-urlencoded'},
41
+ :body => {:consumer_key => options.client_id, :redirect_uri => callback_url}
42
+ })
43
+ session['omniauth.pocket.token'] = response.parsed['code']
44
+ end
45
+
46
+ def build_access_token
47
+ client.get_token({:consumer_key => options.client_id, :code => session.delete('omniauth.pocket.token')})
48
+ end
49
+
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-pocket-oauth2/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Greg Leppert"]
6
+ gem.email = ["greg@leppert.me"]
7
+ gem.description = "An Omniauth Strategy for Pocket"
8
+ gem.summary = "An Omniauth Strategy for Pocket"
9
+ gem.homepage = "https://github.com/andyw8/omniauth-pocket-oauth2"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "omniauth-pocket-oauth2"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Omniauth::Pocket::VERSION
17
+
18
+ gem.add_dependency 'omniauth', '>= 1.0'
19
+ gem.add_dependency 'omniauth-oauth2', '>= 1.0'
20
+ gem.add_development_dependency "rspec", "~> 2.7"
21
+ gem.add_development_dependency 'rack-test'
22
+ gem.add_development_dependency 'simplecov'
23
+ gem.add_development_dependency 'webmock'
24
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Pocket do
4
+
5
+ subject do
6
+ OmniAuth::Strategies::Pocket.new({})
7
+ end
8
+
9
+ context "general" do
10
+ it "should be called pocket" do
11
+ subject.options.name.should eq('pocket')
12
+ end
13
+ end
14
+
15
+ context "endpoints" do
16
+ it "has correct site" do
17
+ subject.options.client_options.site.should eq("https://getpocket.com")
18
+ end
19
+
20
+ it "has correct authorize_url" do
21
+ subject.options.client_options.authorize_url.should eq("https://getpocket.com/auth/authorize")
22
+ end
23
+
24
+ it "has correct token_url" do
25
+ subject.options.client_options.token_url.should eq("https://getpocket.com/v3/oauth/authorize")
26
+ end
27
+ end
28
+
29
+ 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-pocket-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,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-pocket-oauth2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Greg Leppert
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-04-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
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: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rack-test
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: simplecov
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
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: An Omniauth Strategy for Pocket
98
+ email:
99
+ - greg@leppert.me
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - Gemfile
106
+ - LICENSE
107
+ - README.md
108
+ - Rakefile
109
+ - lib/omniauth-pocket-oauth2.rb
110
+ - lib/omniauth-pocket-oauth2/version.rb
111
+ - lib/omniauth-pocket.rb
112
+ - lib/omniauth/strategies/pocket.rb
113
+ - omniauth-pocket-oauth2.gemspec
114
+ - spec/omniauth/strategies/pocket_spec.rb
115
+ - spec/spec_helper.rb
116
+ homepage: https://github.com/andyw8/omniauth-pocket-oauth2
117
+ licenses: []
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubygems_version: 3.0.3
135
+ signing_key:
136
+ specification_version: 4
137
+ summary: An Omniauth Strategy for Pocket
138
+ test_files:
139
+ - spec/omniauth/strategies/pocket_spec.rb
140
+ - spec/spec_helper.rb