Skip to content

Commit bfab6cc

Browse files
committed
Merge branch 'master' of github.com:SecurableIO/Auth-Tool
2 parents 55c0ff4 + 311bdd8 commit bfab6cc

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

lib/auth_tool.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ module AuthTool
1010
# The client_secrets hash for the API
1111
#
1212
# @return [AuthTool::Client] The client.
13-
def self.get_client client_secrets
13+
def self.get_client(client_secrets, token = {})
1414
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 != {}
1617
return client
1718
end
1819

@@ -95,7 +96,12 @@ def self.call(client, http_verb, uri, params = {})
9596
# Configuration options for the client.
9697
#
9798
# @return [AuthTool::Client] New client object
98-
def self.create_client options
99-
AuthTool::Client.new options
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
100106
end
101107
end

lib/auth_tool/client.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def initialize(options, *args)
1919
self.params = config.delete('params') if @has_params
2020
if @oauth_version == 1
2121
oauth1 config
22+
puts 'SSLDKJFKLSDJFKLSDJFKLDSJKLFJDSKLFJDSJFKLDSJFKLDSF'
2223
self.signet.token_credential_key = credentials["oauth_token"] if credentials.has_key? "oauth_token"
2324
self.signet.token_credential_secret = credentials["oauth_token_secret"] if credentials.has_key? "oauth_token_secret"
2425
elsif @oauth_version == 2

lib/auth_tool/oauth_1.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ def self.call(client, http_verb = 'get', uri, params)
6464
body = params.delete('body') if params.has_key? 'body'
6565
conn = Faraday.new(:params => params)
6666
options = {:method => http_verb, :header => header, :body => body, :uri => uri, :connection => conn}
67-
67+
6868
begin
6969
response = client.signet.fetch_protected_resource(options)
7070
rescue
7171
p 'fetch_protected_resource failed'
7272
end
73-
73+
7474
return JSON.parse(response.body)
7575
end
7676
end

0 commit comments

Comments
 (0)