auth_tool 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/auth_tool.rb +10 -4
- data/lib/auth_tool/client.rb +1 -0
- data/lib/auth_tool/oauth_1.rb +2 -2
- data/lib/auth_tool/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50647a7619ee11aca94acc9cb48eb8e517f9b2d8
|
4
|
+
data.tar.gz: b598d2b0ce0a554fbefb178685794e8e987d125e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00b4c0188e4a86796528021e2cec560b47a791308b4ca542d87d6d02a72afd93091d02b3465fc8899a03c0d756afb146ab94503ae9c58622790979b79cfa1b31
|
7
|
+
data.tar.gz: 8e1d72a3f334ba3d6bed4587b865fa7c9fd780a448b621f6f2d9dfeec4bf6edf774dae202a86589e4546f7c4ebeaf8c503f828dde4d60b48cca38137b5798588
|
data/lib/auth_tool.rb
CHANGED
@@ -10,9 +10,10 @@ module AuthTool
|
|
10
10
|
# The client_secrets hash for the API
|
11
11
|
#
|
12
12
|
# @return [AuthTool::Client] The client.
|
13
|
-
def self.get_client
|
13
|
+
def self.get_client(client_secrets, token = {})
|
14
14
|
raise "Expected Hash, received #{client_secrets.class}" if client_secrets.class != Hash
|
15
|
-
client = create_client(client_secrets)
|
15
|
+
client = create_client(client_secrets) if token == {}
|
16
|
+
client = create_client(client_secrets, token) if token != {}
|
16
17
|
return client
|
17
18
|
end
|
18
19
|
|
@@ -95,7 +96,12 @@ module AuthTool
|
|
95
96
|
# Configuration options for the client.
|
96
97
|
#
|
97
98
|
# @return [AuthTool::Client] New client object
|
98
|
-
def self.create_client
|
99
|
-
|
99
|
+
def self.create_client(options, *token)
|
100
|
+
|
101
|
+
if token.length > 0
|
102
|
+
AuthTool::Client.new(options,token[0])
|
103
|
+
else
|
104
|
+
AuthTool::Client.new(options)
|
105
|
+
end
|
100
106
|
end
|
101
107
|
end
|
data/lib/auth_tool/client.rb
CHANGED
@@ -19,6 +19,7 @@ module AuthTool
|
|
19
19
|
self.params = config.delete('params') if @has_params
|
20
20
|
if @oauth_version == 1
|
21
21
|
oauth1 config
|
22
|
+
puts 'SSLDKJFKLSDJFKLSDJFKLDSJKLFJDSKLFJDSJFKLDSJFKLDSF'
|
22
23
|
self.signet.token_credential_key = credentials["oauth_token"] if credentials.has_key? "oauth_token"
|
23
24
|
self.signet.token_credential_secret = credentials["oauth_token_secret"] if credentials.has_key? "oauth_token_secret"
|
24
25
|
elsif @oauth_version == 2
|
data/lib/auth_tool/oauth_1.rb
CHANGED
@@ -64,13 +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
68
|
begin
|
69
69
|
response = client.signet.fetch_protected_resource(options)
|
70
70
|
rescue
|
71
71
|
p 'fetch_protected_resource failed'
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
return JSON.parse(response.body)
|
75
75
|
end
|
76
76
|
end
|
data/lib/auth_tool/version.rb
CHANGED