simple-oauth2 0.1.1 → 0.1.2
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 +4 -4
- data/lib/simple-oauth2.rb +9 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b037cb1cb09dbcbf5bdc7f18702c38015365866
|
4
|
+
data.tar.gz: d0ff5dbca25265b7b047ed2ed7f5914ea9982b8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89a043c7098d258635789280a81098991037c9e2e5232c46f8523bdb048340168c88d3e6f5b52cd1bd978cd30c40d8c587547b4c15b78d0ae5a4d5aa238a675a
|
7
|
+
data.tar.gz: 9576c88267b3a9b744323af24c1d28d66c7753cb0da62555b37b7a7ad7a3f935ca8c498a008a43222c10136f620314d59511440f0d6987532396e56e263ca882
|
data/lib/simple-oauth2.rb
CHANGED
@@ -2,10 +2,10 @@ require "faraday"
|
|
2
2
|
require "addressable/template"
|
3
3
|
require "addressable/uri"
|
4
4
|
require "json"
|
5
|
+
require "models/response"
|
5
6
|
|
6
7
|
module Simple
|
7
8
|
module Oauth2
|
8
|
-
|
9
9
|
class Client
|
10
10
|
attr_accessor :client_id,
|
11
11
|
:client_secret,
|
@@ -43,18 +43,14 @@ module Simple
|
|
43
43
|
redirect_uri: @redirect_uri,
|
44
44
|
client_secret: @client_secret
|
45
45
|
}
|
46
|
-
|
47
|
-
conn = Faraday.new(:url =>
|
48
|
-
response = conn.post
|
49
|
-
|
50
|
-
return {
|
51
|
-
access_token: response['access_token'],
|
52
|
-
expires_in: response['expires_in']
|
53
|
-
}
|
46
|
+
url = "#{@base_uri}#{@token_endpoint}?#{params.query}"
|
47
|
+
conn = Faraday.new(:url => url)
|
48
|
+
response = conn.post url
|
49
|
+
Response.new(response.body)
|
54
50
|
end
|
55
51
|
|
56
52
|
# Exchanges a verification code for an access token.
|
57
|
-
def
|
53
|
+
def exchange(code)
|
58
54
|
params = Addressable::URI.new
|
59
55
|
params.query_values = {
|
60
56
|
type: 'web_server',
|
@@ -66,11 +62,8 @@ module Simple
|
|
66
62
|
uri = "#{@base_uri}#{@token_endpoint}?#{params.query}"
|
67
63
|
conn = Faraday.new(:url => uri)
|
68
64
|
response = conn.post uri
|
69
|
-
|
70
|
-
|
71
|
-
access_token: response['access_token'],
|
72
|
-
expires_in: response['expires_in']
|
73
|
-
}
|
65
|
+
binding.pry
|
66
|
+
Response.new(response.body)
|
74
67
|
end
|
75
68
|
|
76
69
|
# Returns redirect url.
|
@@ -85,4 +78,4 @@ module Simple
|
|
85
78
|
end
|
86
79
|
end
|
87
80
|
end
|
88
|
-
end
|
81
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mitch Stewart
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|