Spaces:
Runtime error
Runtime error
Upload main_app.py
Browse files- main_app.py +9 -2
main_app.py
CHANGED
|
@@ -60,14 +60,21 @@ def get_hf_token(code: str, redirect_uri: str) -> dict | None:
|
|
| 60 |
"client_id": CLIENT_ID,
|
| 61 |
"client_secret": CLIENT_SECRET,
|
| 62 |
}
|
|
|
|
|
|
|
|
|
|
| 63 |
try:
|
| 64 |
response = requests.post(url, data=payload)
|
| 65 |
-
response.raise_for_status()
|
| 66 |
return response.json()
|
| 67 |
except requests.exceptions.RequestException as e:
|
| 68 |
st.error(f"トークンの取得に失敗しました: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
return None
|
| 70 |
-
|
| 71 |
def get_user_info(access_token: str) -> dict | None:
|
| 72 |
"""アクセストークンを使ってユーザー情報を取得する"""
|
| 73 |
url = f"{HF_ENDPOINT}/api/whoami"
|
|
|
|
| 60 |
"client_id": CLIENT_ID,
|
| 61 |
"client_secret": CLIENT_SECRET,
|
| 62 |
}
|
| 63 |
+
st.info("ステップ1.5: トークン交換リクエストを送信します。ペイロード:")
|
| 64 |
+
st.json(payload) # 送信する内容を画面に表示
|
| 65 |
+
|
| 66 |
try:
|
| 67 |
response = requests.post(url, data=payload)
|
| 68 |
+
response.raise_for_status()
|
| 69 |
return response.json()
|
| 70 |
except requests.exceptions.RequestException as e:
|
| 71 |
st.error(f"トークンの取得に失敗しました: {e}")
|
| 72 |
+
# vvv この行が最重要!サーバーからのエラーレスポンスを直接表示 vvv
|
| 73 |
+
if hasattr(e, 'response') and e.response is not None:
|
| 74 |
+
st.error("サーバーからの詳細なエラーレスポンス:")
|
| 75 |
+
st.json(e.response.json())
|
| 76 |
return None
|
| 77 |
+
|
| 78 |
def get_user_info(access_token: str) -> dict | None:
|
| 79 |
"""アクセストークンを使ってユーザー情報を取得する"""
|
| 80 |
url = f"{HF_ENDPOINT}/api/whoami"
|