auth_tool 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/auth_tool/oauth_1.rb +7 -1
- data/lib/auth_tool/oauth_2.rb +15 -1
- data/lib/auth_tool/version.rb +1 -1
- 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: 64d7ddbec2f9ffe6038aa009d72142db863cbee3
|
4
|
+
data.tar.gz: 9bdfcdf5682e032bbb7bfeabcd51da94998bc276
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58ae32616d66ecc29f33353ae27f5df50858d4606edd64ed4c78bf1a311c5edec0a92444a38338ecda313865c573b574ad156c751a058aa70fd234f25d6ed60e
|
7
|
+
data.tar.gz: 5195d8aff6dc86ae110bd72d1ef506592639d1d9ea95b72ac0bf077a1ae6003ec222508899841eafca2e3fef4b19135fda48fe3b32291afc8934ee58334581d2
|
data/README.md
CHANGED
@@ -5,15 +5,15 @@ General purpose OAuth tool for API integrations. Utilizes [signet](https://githu
|
|
5
5
|
Usage
|
6
6
|
---
|
7
7
|
```
|
8
|
-
require '
|
8
|
+
require 'atuh_tool'
|
9
9
|
|
10
|
-
client = AuthTool::get_client
|
10
|
+
client = AuthTool::get_client {secrets hash}
|
11
11
|
AuthTool::get_redirect_url client
|
12
12
|
|
13
13
|
# receive data from front-end
|
14
14
|
|
15
15
|
AuthTool::receive(client,response)
|
16
|
-
AuthTool::call(client, "https://api.example.com/endpoint", params)
|
16
|
+
AuthTool::call(client, "get" "https://api.example.com/endpoint", params)
|
17
17
|
```
|
18
18
|
GET
|
19
19
|
---
|
data/lib/auth_tool/oauth_1.rb
CHANGED
@@ -64,7 +64,13 @@ module AuthTool
|
|
64
64
|
body = params.delete('body') if params.has_key? 'body'
|
65
65
|
conn = Faraday.new(:params => params)
|
66
66
|
options = {:method => http_verb, :header => header, :body => body, :uri => uri, :connection => conn}
|
67
|
-
|
67
|
+
|
68
|
+
begin
|
69
|
+
response = client.signet.fetch_protected_resource(options)
|
70
|
+
rescue
|
71
|
+
p 'fetch_protected_resource failed'
|
72
|
+
end
|
73
|
+
|
68
74
|
return JSON.parse(response.body)
|
69
75
|
end
|
70
76
|
end
|
data/lib/auth_tool/oauth_2.rb
CHANGED
@@ -53,7 +53,21 @@ module AuthTool
|
|
53
53
|
body = params.delete('body') if params.has_key? 'body'
|
54
54
|
conn = Faraday.new(:params => params)
|
55
55
|
options = {:method => http_verb, :header => header, :body => body, :uri => uri, :connection => conn}
|
56
|
-
|
56
|
+
|
57
|
+
|
58
|
+
# handle faraday's 401 error
|
59
|
+
begin
|
60
|
+
response = client.signet.fetch_protected_resource(options)
|
61
|
+
rescue
|
62
|
+
client.refresh
|
63
|
+
end
|
64
|
+
|
65
|
+
begin
|
66
|
+
response = client.signet.fetch_protected_resource(options)
|
67
|
+
rescue
|
68
|
+
p 'fetch_protected_resource failed'
|
69
|
+
end
|
70
|
+
|
57
71
|
return JSON.parse(response.body)
|
58
72
|
end
|
59
73
|
end
|
data/lib/auth_tool/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auth_tool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Fan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|