Skip to content

Commit 7888de8

Browse files
committed
Remove oob fallback
1 parent 1da3606 commit 7888de8

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

lib/aws/google.rb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def silence_output
108108
end
109109

110110
def get_oauth_code(client, options)
111-
raise 'fallback' unless @port && !@port.zero?
111+
raise ArgumentError.new('Missing port for local oauth server') unless @port && !@port.zero?
112112

113113
require 'launchy'
114114
require 'webrick'
@@ -135,20 +135,17 @@ def get_oauth_code(client, options)
135135
end
136136
end
137137
while server_thread.alive?
138-
raise 'fallback' if !launchy.alive? && !launchy.value.success?
138+
unless launchy.alive? && launchy.value.success?
139+
server.shutdown
140+
raise RuntimeError.new('Failed to launch browser with Launchy')
141+
end
139142

140143
sleep 0.1
141144
end
142145
end
143-
code || raise('fallback')
144-
rescue StandardError
146+
code || raise('Local Google Oauth failed to get code')
147+
ensure
145148
trap('INT', 'DEFAULT')
146-
# Fallback to out-of-band authentication if browser launch failed.
147-
client.redirect_uri = 'oob'
148-
return ENV['OAUTH_CODE'] if ENV['OAUTH_CODE']
149-
150-
raise RuntimeError, 'Open the following URL in a browser to get a code,' \
151-
"export to $OAUTH_CODE and rerun:\n#{client.authorization_uri(options)}", []
152149
end
153150

154151
def refresh

0 commit comments

Comments
 (0)