Skip to content
This repository was archived by the owner on Jan 27, 2023. It is now read-only.

Commit 32fb1ed

Browse files
authored
Merge pull request #21 from cipherstash/feat/headless-login
catch launchy exception
2 parents ce39f84 + eb9f30c commit 32fb1ed

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

lib/cipherstash/client/auth0_device_code_credentials.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,17 @@ def get_device_code_polling_info
148148
def prompt_user(polling_info)
149149
code = polling_info[:user_code]
150150

151-
Launchy.open polling_info[:verification_uri_complete]
151+
begin
152+
Launchy.open polling_info[:verification_uri_complete]
153+
rescue Launchy::Error
154+
# We could be running in a headless environment, in which case, the user should just open the url in a browser on a separate machine
155+
@logger.debug("Auth0DeviceCodeCredentials#prompt_user") { "Unable to launch URL in browser" }
156+
end
152157

153158
puts <<~EOF
159+
160+
### ACTION REQUIRED ###
161+
154162
Visit \e[92m#{polling_info[:verification_uri_complete]}\e[0m to complete authentication by following the below steps:
155163
156164
1. Verify that this code matches the code in your browser

0 commit comments

Comments
 (0)