Commit
·
2c28e07
1
Parent(s):
468feab
Update app.py
Browse files
app.py
CHANGED
|
@@ -472,17 +472,18 @@ def run_captioning(*inputs):
|
|
| 472 |
|
| 473 |
def check_token(OAuthToken: gr.OAuthToken | None):
|
| 474 |
token = OAuthToken.token
|
| 475 |
-
print(OAuthToken)
|
| 476 |
try:
|
| 477 |
api = HfApi(token=token)
|
| 478 |
user_data = api.whoami()
|
| 479 |
print(user_data)
|
|
|
|
| 480 |
except Exception as e:
|
| 481 |
gr.Warning("Invalid user token. Make sure to get your Hugging Face token from the settings page")
|
| 482 |
return gr.update(visible=False), gr.update(visible=False)
|
| 483 |
else:
|
| 484 |
-
if (
|
| 485 |
-
gr.Warning("Ops, you'
|
| 486 |
else:
|
| 487 |
if user_data['canPay']:
|
| 488 |
return gr.update(visible=False), gr.update(visible=True)
|
|
|
|
| 472 |
|
| 473 |
def check_token(OAuthToken: gr.OAuthToken | None):
|
| 474 |
token = OAuthToken.token
|
| 475 |
+
print(OAuthToken.scope)
|
| 476 |
try:
|
| 477 |
api = HfApi(token=token)
|
| 478 |
user_data = api.whoami()
|
| 479 |
print(user_data)
|
| 480 |
+
print("CanPay", user_data['canPay'])
|
| 481 |
except Exception as e:
|
| 482 |
gr.Warning("Invalid user token. Make sure to get your Hugging Face token from the settings page")
|
| 483 |
return gr.update(visible=False), gr.update(visible=False)
|
| 484 |
else:
|
| 485 |
+
if ("write_repos" not in OAuthToken.scope):
|
| 486 |
+
gr.Warning("Ops, you didn't give Write Repos access")
|
| 487 |
else:
|
| 488 |
if user_data['canPay']:
|
| 489 |
return gr.update(visible=False), gr.update(visible=True)
|