Spaces:
Running
Running
update
Browse files
app.py
CHANGED
|
@@ -581,77 +581,21 @@ The OAuth token appears to be invalid or in the wrong format. Please try logging
|
|
| 581 |
user_info = test_api.whoami()
|
| 582 |
print(f"Debug: Token test successful - user: {user_info.get('name', 'unknown')}")
|
| 583 |
|
| 584 |
-
#
|
| 585 |
try:
|
| 586 |
-
|
| 587 |
-
|
|
|
|
| 588 |
|
| 589 |
-
#
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
user_info = test_api.whoami()
|
| 593 |
-
print(f"Debug: User info: {user_info}")
|
| 594 |
-
|
| 595 |
-
# Check if user has pro account or sufficient permissions
|
| 596 |
-
if user_info.get('type') == 'user':
|
| 597 |
-
print("Debug: User account type confirmed")
|
| 598 |
-
else:
|
| 599 |
-
print(f"Debug: User account type: {user_info.get('type', 'unknown')}")
|
| 600 |
-
|
| 601 |
-
except Exception as user_info_error:
|
| 602 |
-
print(f"Debug: Could not get detailed user info: {user_info_error}")
|
| 603 |
-
|
| 604 |
-
except Exception as repo_error:
|
| 605 |
-
print(f"Debug: Could not list repos: {repo_error}")
|
| 606 |
-
|
| 607 |
-
# Check if this is a scope/permission issue
|
| 608 |
-
error_msg = str(repo_error).lower()
|
| 609 |
-
if "403" in error_msg or "forbidden" in error_msg or "unauthorized" in error_msg:
|
| 610 |
-
return """β **Insufficient Permissions**
|
| 611 |
-
|
| 612 |
-
Your Hugging Face account doesn't have the necessary permissions to create spaces. This could be because:
|
| 613 |
-
|
| 614 |
-
1. **Missing OAuth Scopes**: You didn't grant all the required permissions during login
|
| 615 |
-
2. **Account Restrictions**: Your account has restrictions on creating repositories
|
| 616 |
-
3. **Token Scope Issues**: The OAuth token doesn't include the necessary scopes
|
| 617 |
-
|
| 618 |
-
**Required Permissions:**
|
| 619 |
-
- `read-repos` - Read access to repositories
|
| 620 |
-
- `write-repos` - Write access to create repositories
|
| 621 |
-
- `manage-repos` - Manage repository settings
|
| 622 |
-
|
| 623 |
-
**Steps to fix:**
|
| 624 |
-
1. **Logout**: Click the logout button in the sidebar
|
| 625 |
-
2. **Login Again**: Click "Sign in with Hugging Face" again
|
| 626 |
-
3. **Grant All Permissions**: When the authorization page appears, make sure to check ALL the requested permissions:
|
| 627 |
-
- β
read-repos
|
| 628 |
-
- β
write-repos
|
| 629 |
-
- β
manage-repos
|
| 630 |
-
4. **Complete Authorization**: Click "Authorize" to complete the login
|
| 631 |
-
5. **Try Deploying**: Try deploying again
|
| 632 |
-
|
| 633 |
-
**Important:** Make sure you see all three permissions checked on the authorization page before clicking "Authorize".
|
| 634 |
-
|
| 635 |
-
---
|
| 636 |
-
*Please log in again with full permissions.*""", update_oauth_status(oauth_profile, oauth_token)
|
| 637 |
else:
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
This
|
| 643 |
-
- Network connectivity issues
|
| 644 |
-
- Hugging Face API temporary problems
|
| 645 |
-
- Account-specific restrictions
|
| 646 |
-
|
| 647 |
-
**Steps to fix:**
|
| 648 |
-
1. Check your internet connection
|
| 649 |
-
2. Try logging out and logging back in
|
| 650 |
-
3. Wait a few minutes and try again
|
| 651 |
-
4. If the problem persists, check your Hugging Face account settings
|
| 652 |
-
|
| 653 |
-
---
|
| 654 |
-
*Please try again or contact support if the issue persists.*""", update_oauth_status(oauth_profile, oauth_token)
|
| 655 |
|
| 656 |
except Exception as token_error:
|
| 657 |
print(f"Debug: Token test failed: {token_error}")
|
|
|
|
| 581 |
user_info = test_api.whoami()
|
| 582 |
print(f"Debug: Token test successful - user: {user_info.get('name', 'unknown')}")
|
| 583 |
|
| 584 |
+
# Test if user can create repositories by checking their account type
|
| 585 |
try:
|
| 586 |
+
# Try to get user info to check account capabilities
|
| 587 |
+
user_info = test_api.whoami()
|
| 588 |
+
print(f"Debug: User info: {user_info}")
|
| 589 |
|
| 590 |
+
# Check if user has pro account or sufficient permissions
|
| 591 |
+
if user_info.get('type') == 'user':
|
| 592 |
+
print("Debug: User account type confirmed")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 593 |
else:
|
| 594 |
+
print(f"Debug: User account type: {user_info.get('type', 'unknown')}")
|
| 595 |
+
|
| 596 |
+
except Exception as user_info_error:
|
| 597 |
+
print(f"Debug: Could not get detailed user info: {user_info_error}")
|
| 598 |
+
# This is not a critical error, so we continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 599 |
|
| 600 |
except Exception as token_error:
|
| 601 |
print(f"Debug: Token test failed: {token_error}")
|