Skip to content

Commit b20a3e6

Browse files
committed
Updated oauth error messages
1 parent e980e3b commit b20a3e6

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/hermes/commands/init/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,8 @@ def configure_github(self) -> None:
623623
token=self.tokens[GitHoster.GitHub])
624624
oauth_success = True
625625
else:
626-
sc.echo("Something went wrong while doing OAuth. You'll have to do it manually instead.",
626+
sc.echo("Something went wrong while doing OAuth. You will have to restart 'hermes init' to try OAuth "
627+
"again. Alternatively you can do it manually instead by executing the following steps:",
627628
formatting=sc.Formats.WARNING)
628629
if not oauth_success:
629630
sc.echo("Add the {} token{} to your {} under the name {}.".format(

src/hermes/commands/init/util/oauth_process.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
PREFER_DEVICE_FLOW = True
2525
DEACTIVATE_BROWSER_OPENING = False
2626

27-
2827
def setup_logging_for_oauthlib():
2928
"""
3029
This makes requests_oauthlib.oauth2_session print all the debug logs onto the console.
@@ -160,10 +159,10 @@ def get_tokens_from_device_flow(self) -> dict[str: str]:
160159
if "access_token" in token_response_data:
161160
return token_response_data
162161
elif "error" in token_response_data and token_response_data["error"] != "authorization_pending":
163-
sc.echo(f"Error: {token_response_data['error']}", sc.Formats.WARNING)
162+
sc.echo(f"Device Flow Error: {token_response_data['error']}", sc.Formats.WARNING)
164163
return {}
165164
elif self.error_description:
166-
sc.echo(f"Error: {self.error_description}", sc.Formats.WARNING)
165+
sc.echo(f"Device Flow Error: {self.error_description}", sc.Formats.WARNING)
167166
return {}
168167

169168
time.sleep(interval)
@@ -172,7 +171,7 @@ def get_tokens_from_oauth(self) -> dict[str: str]:
172171
if self.authorize_url == "":
173172
sc.echo(f"OAuth is not available for {self.name}")
174173
return {}
175-
# sc.echo(f"Opening browser to log into your {self.name} account...")
174+
sc.echo(f"Opening browser to log into your {self.name} account...")
176175
self.tokens = {}
177176
server_thread = threading.Thread(target=self.start_server, daemon=True)
178177
server_thread.start()
@@ -187,9 +186,9 @@ def get_tokens_from_oauth(self) -> dict[str: str]:
187186

188187
def get_tokens(self) -> dict[str: str]:
189188
if PREFER_DEVICE_FLOW:
190-
return self.get_tokens_from_device_flow() or self.get_tokens_from_oauth() or {}
189+
return self.get_tokens_from_device_flow() or {}
191190
else:
192-
return self.get_tokens_from_oauth() or self.get_tokens_from_device_flow() or {}
191+
return self.get_tokens_from_oauth() or {}
193192

194193

195194
class Handler(BaseHTTPRequestHandler):

0 commit comments

Comments
 (0)