1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[compute|rackspace] fix for token expiry/reauth

closes #421
This commit is contained in:
geemus 2011-07-15 17:16:12 -05:00
parent 7eb360636a
commit 5c6ca0ee22

View file

@ -94,7 +94,7 @@ module Fog
def request(params)
begin
response = @connection.request(params.merge!({
response = @connection.request(params.merge({
:headers => {
'Content-Type' => 'application/json',
'X-Auth-Token' => @auth_token
@ -104,11 +104,11 @@ module Fog
:query => ('ignore_awful_caching' << Time.now.to_i.to_s)
}))
rescue Excon::Errors::Unauthorized => error
if JSON.parse(response.body)['unauthorized']['message'] == 'Invalid authentication token. Please renew.'
if error.response.body != 'Bad username or password' # token expiration
@rackspace_must_reauthenticate = true
authenticate
retry
else
else # bad credentials
raise error
end
rescue Excon::Errors::HTTPStatusError => error