omniauth-medium 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +33 -5
- data/examples/sinatra/.env +3 -0
- data/examples/sinatra/Gemfile +8 -0
- data/examples/sinatra/Gemfile.lock +48 -0
- data/examples/sinatra/config.ru +37 -0
- data/lib/omniauth-medium.rb +2 -0
- data/lib/{omniauth/medium → omniauth-medium}/version.rb +1 -1
- data/lib/omniauth/strategies/medium.rb +20 -0
- data/omniauth-medium.gemspec +14 -12
- metadata +23 -4
- data/lib/omniauth/medium.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66cc6f63c5789b2750d51f20f6c73434a8e53dfe
|
4
|
+
data.tar.gz: 66acad21da93f933faf70f65619bb94e47391382
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 968607eb21ac2e6e1788d6b4829f65017fa7ee34f3f345cb1161bce841653739252d82fe4535ec7d0f73df2d5dedf597681cafd71de7a773166bd00aa999425b
|
7
|
+
data.tar.gz: 34aef3217ae1374d606dd765556c6b738ef7c6e9b7c2ebbc368d9caab21ddf519b29f98b8ead3c0b0d8309f2e68d4507f8bc757d920c7e6404c4f0ec74c66dfa
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# Omniauth::Medium
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/omniauth-medium.svg)](https://badge.fury.io/rb/omniauth-medium)
|
2
3
|
|
3
|
-
|
4
|
+
This is an unofficial OmniAuth strategy for authenticating through Medium.
|
5
|
+
|
6
|
+
To use it, you'll need to [register a new OAuth application](https://medium.com/me/applications/new) with Medium.
|
4
7
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
@@ -20,9 +22,35 @@ Or install it yourself as:
|
|
20
22
|
|
21
23
|
$ gem install omniauth-medium
|
22
24
|
|
23
|
-
## Usage
|
25
|
+
## Basic Usage
|
26
|
+
|
27
|
+
use OmniAuth::Builder do
|
28
|
+
provider :medium, ENV['MEDIUM_CLIENT_ID'], ENV['MEDIUM_CLIENT_SECRET']
|
29
|
+
end
|
24
30
|
|
25
|
-
|
31
|
+
## Example Omniauth Hash
|
32
|
+
```
|
33
|
+
{
|
34
|
+
"provider"=>"medium",
|
35
|
+
"uid"=>"1ec92d6f7dc96f3c95dfa0100d0bf03f36d2fe6b27a15b5c3061609866650d484",
|
36
|
+
"info"=>{
|
37
|
+
"id"=>"1ec92d6f7dc96f3c95dfa0100d0bf03f36d2fe6b27a15b5c3061609866650d484",
|
38
|
+
"username"=>"adamkirkwood",
|
39
|
+
"name"=>"Adam Kirkwood",
|
40
|
+
"url"=>"https://medium.com/@adamkirkwood",
|
41
|
+
"imageUrl"=>"https://cdn-images-1.medium.com/fit/c/200/200/0*lBXH3ieYv40OwIlo.jpeg"
|
42
|
+
},
|
43
|
+
"credentials"=>{
|
44
|
+
"token"=>"...",
|
45
|
+
"refresh_token"=>"...",
|
46
|
+
"expires_at"=>...,
|
47
|
+
"expires"=>true
|
48
|
+
},
|
49
|
+
"extra"=>{
|
50
|
+
|
51
|
+
}
|
52
|
+
}
|
53
|
+
```
|
26
54
|
|
27
55
|
## Development
|
28
56
|
|
@@ -32,7 +60,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
60
|
|
33
61
|
## Contributing
|
34
62
|
|
35
|
-
1. Fork it ( https://github.com/
|
63
|
+
1. Fork it ( https://github.com/adamkirkwood/omniauth-medium/fork )
|
36
64
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
65
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
66
|
4. Push to the branch (`git push origin my-new-feature`)
|
@@ -0,0 +1,48 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../../
|
3
|
+
specs:
|
4
|
+
omniauth-medium (1.0.1)
|
5
|
+
omniauth-oauth2 (~> 1.3.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
dotenv (2.0.2)
|
11
|
+
faraday (0.9.2)
|
12
|
+
multipart-post (>= 1.2, < 3)
|
13
|
+
hashie (3.4.3)
|
14
|
+
jwt (1.5.2)
|
15
|
+
multi_json (1.11.2)
|
16
|
+
multi_xml (0.5.5)
|
17
|
+
multipart-post (2.0.0)
|
18
|
+
oauth2 (1.0.0)
|
19
|
+
faraday (>= 0.8, < 0.10)
|
20
|
+
jwt (~> 1.0)
|
21
|
+
multi_json (~> 1.3)
|
22
|
+
multi_xml (~> 0.5)
|
23
|
+
rack (~> 1.2)
|
24
|
+
omniauth (1.2.2)
|
25
|
+
hashie (>= 1.2, < 4)
|
26
|
+
rack (~> 1.0)
|
27
|
+
omniauth-oauth2 (1.3.1)
|
28
|
+
oauth2 (~> 1.0)
|
29
|
+
omniauth (~> 1.2)
|
30
|
+
rack (1.6.4)
|
31
|
+
rack-protection (1.5.3)
|
32
|
+
rack
|
33
|
+
sinatra (1.4.6)
|
34
|
+
rack (~> 1.4)
|
35
|
+
rack-protection (~> 1.4)
|
36
|
+
tilt (>= 1.3, < 3)
|
37
|
+
tilt (2.0.1)
|
38
|
+
|
39
|
+
PLATFORMS
|
40
|
+
ruby
|
41
|
+
|
42
|
+
DEPENDENCIES
|
43
|
+
dotenv
|
44
|
+
multi_json
|
45
|
+
omniauth
|
46
|
+
omniauth-medium!
|
47
|
+
omniauth-oauth2 (~> 1.3.1)
|
48
|
+
sinatra
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'dotenv'
|
2
|
+
Dotenv.load
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'bundler/setup'
|
6
|
+
require 'sinatra'
|
7
|
+
require 'omniauth'
|
8
|
+
require 'omniauth-medium'
|
9
|
+
|
10
|
+
get '/' do
|
11
|
+
<<-HTML
|
12
|
+
<div>
|
13
|
+
Your credentials are :
|
14
|
+
<ul>
|
15
|
+
<li>client id : #{ENV['MEDIUM_CLIENT_ID']}</li>
|
16
|
+
<li>secret key : #{ENV['MEDIUM_CLIENT_SECRET']}</li>
|
17
|
+
</ul>
|
18
|
+
</div>
|
19
|
+
<a href='/auth/medium'>Sign in with Medium</a>
|
20
|
+
HTML
|
21
|
+
end
|
22
|
+
|
23
|
+
get '/auth/:provider/callback' do
|
24
|
+
content_type 'text/plain'
|
25
|
+
request.env['omniauth.auth'].to_hash.inspect rescue "No Data"
|
26
|
+
end
|
27
|
+
|
28
|
+
get '/auth/failure' do
|
29
|
+
content_type 'text/plain'
|
30
|
+
request.env['omniauth.auth'].to_hash.inspect rescue "No Data"
|
31
|
+
end
|
32
|
+
|
33
|
+
use Rack::Session::Cookie, secret: ENV['RACK_COOKIE_SECRET']
|
34
|
+
|
35
|
+
use OmniAuth::Builder do
|
36
|
+
provider :medium, ENV['MEDIUM_CLIENT_ID'], ENV['MEDIUM_CLIENT_SECRET'], scope: 'basicProfile,listPublications'
|
37
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Medium < OmniAuth::Strategies::OAuth2
|
6
|
+
option :name, 'medium'
|
7
|
+
option :scope, 'basicProfile,publishPost'
|
8
|
+
|
9
|
+
option :client_options, {
|
10
|
+
site: 'https://api.medium.com/v1',
|
11
|
+
authorize_url: 'https://medium.com/m/oauth/authorize',
|
12
|
+
token_url: "https://api.medium.com/v1/tokens"
|
13
|
+
}
|
14
|
+
|
15
|
+
uid { info["id"] }
|
16
|
+
|
17
|
+
info { @info ||= access_token.get("me").parsed["data"] }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/omniauth-medium.gemspec
CHANGED
@@ -1,24 +1,26 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'omniauth
|
4
|
+
require 'omniauth-medium/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'omniauth-medium'
|
8
8
|
spec.version = Omniauth::Medium::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Adam Kirkwood']
|
10
|
+
spec.email = ['hello@adamkirkwood.com']
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
12
|
+
spec.summary = 'OmniAuth Strategy for the Medium OAuth2 API'
|
13
|
+
spec.description = 'OmniAuth Strategy for the Medium OAuth2 API'
|
14
|
+
spec.homepage = 'https://github.com/adamkirkwood/omniauth-medium'
|
15
|
+
spec.license = 'MIT'
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.bindir =
|
18
|
+
spec.bindir = 'exe'
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = [
|
20
|
+
spec.require_paths = ['lib']
|
21
21
|
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.9'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
|
25
|
+
spec.add_runtime_dependency 'omniauth-oauth2', '1.3.1'
|
24
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-medium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Kirkwood
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: omniauth-oauth2
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.3.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.1
|
41
55
|
description: OmniAuth Strategy for the Medium OAuth2 API
|
42
56
|
email:
|
43
57
|
- hello@adamkirkwood.com
|
@@ -55,8 +69,13 @@ files:
|
|
55
69
|
- Rakefile
|
56
70
|
- bin/console
|
57
71
|
- bin/setup
|
58
|
-
-
|
59
|
-
-
|
72
|
+
- examples/sinatra/.env
|
73
|
+
- examples/sinatra/Gemfile
|
74
|
+
- examples/sinatra/Gemfile.lock
|
75
|
+
- examples/sinatra/config.ru
|
76
|
+
- lib/omniauth-medium.rb
|
77
|
+
- lib/omniauth-medium/version.rb
|
78
|
+
- lib/omniauth/strategies/medium.rb
|
60
79
|
- omniauth-medium.gemspec
|
61
80
|
homepage: https://github.com/adamkirkwood/omniauth-medium
|
62
81
|
licenses:
|