Skip to content

Commit a9e2728

Browse files
committed
fix: raise auth error properly
1 parent f2e1374 commit a9e2728

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

plugins/twitter/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "twitter-plugin-gamesdk"
7-
version = "0.2.10"
7+
version = "0.2.11"
88
description = "Twitter Plugin for Python SDK for GAME by Virtuals"
99
authors = ["Celeste Ang <celeste@virtuals.io>"]
1010
readme = "README.md"

plugins/twitter/twitter_plugin_gamesdk/game_twitter_auth.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,20 @@ def get_login_url(api_key: str) -> str:
6868
Fetches the login URL from the authentication server.
6969
"""
7070
response = requests.get(f"{BASE_URL}/auth", headers={"x-api-key": api_key})
71-
response.raise_for_status()
72-
return response.json().get("url")
71+
72+
if response.status_code != 200:
73+
try:
74+
error_info = response.json()
75+
message = error_info.get("message", "Unknown error")
76+
status = error_info.get("statusCode", response.status_code)
77+
78+
print(f"Auth Error: {message} (Status: {status})")
79+
except Exception:
80+
print(f"Failed to parse error. Raw response:\n{response.text}")
81+
message = response.text
82+
raise Exception(f"Auth request failed: {message}")
83+
else:
84+
return response.json().get("url")
7385

7486
@staticmethod
7587
def verify_auth(code: str, state: str) -> str:

0 commit comments

Comments
 (0)