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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70920dcd4afbb68a32b3195629f9fb62a042326f
4
- data.tar.gz: 3be6cf4fd1567d7452a48a674a1ee336cf7ec550
3
+ metadata.gz: 64d7ddbec2f9ffe6038aa009d72142db863cbee3
4
+ data.tar.gz: 9bdfcdf5682e032bbb7bfeabcd51da94998bc276
5
5
  SHA512:
6
- metadata.gz: ed388c1d6a97eacfa9fd7fa6b39d990892ad0efd56a71f7b4670e7cad80608dc8a5e9040350ee52fd098b737e6e30bf78abd48cf01cc4685daabdd28a8eaf7f4
7
- data.tar.gz: 4c76d3c359f7d537751d4e7b24f359fc440c2f8e97621ad6ad2c06cbc884353a510d86405685023e2c6c30573f121021d869e0cf90191dc629c8f0a9d9aeeac9
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 'auth_tool'
8
+ require 'atuh_tool'
9
9
 
10
- client = AuthTool::get_client 'twitter'
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
  ---
@@ -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
- response = client.signet.fetch_protected_resource(options)
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
@@ -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
- response = client.signet.fetch_protected_resource(options)
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
@@ -1,3 +1,3 @@
1
1
  module AuthTool
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
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.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-05-31 00:00:00.000000000 Z
11
+ date: 2017-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler