update
Browse files580 unmodified lines581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657580 unmodified linesuser_info = test_api.whoami()print(f"Debug: Token test successful - user: {user_info.get('name', 'unknown')}")# Check if user has the necessary permissions by trying to list their repostry:repos = test_api.list_repos(author=username, token=user_token)print(f"Debug: User has {len(list(repos))} repositories")# Test if user can create repositories by checking their account typetry:# Try to get user info to check account capabilitiesuser_info = test_api.whoami()print(f"Debug: User info: {user_info}")# Check if user has pro account or sufficient permissionsif user_info.get('type') == 'user':print("Debug: User account type confirmed")else:print(f"Debug: User account type: {user_info.get('type', 'unknown')}")except Exception as user_info_error:print(f"Debug: Could not get detailed user info: {user_info_error}")except Exception as repo_error:print(f"Debug: Could not list repos: {repo_error}")# Check if this is a scope/permission issueerror_msg = str(repo_error).lower()if "403" in error_msg or "forbidden" in error_msg or "unauthorized" in error_msg:return """β **Insufficient Permissions**Your Hugging Face account doesn't have the necessary permissions to create spaces. This could be because:1. **Missing OAuth Scopes**: You didn't grant all the required permissions during login2. **Account Restrictions**: Your account has restrictions on creating repositories3. **Token Scope Issues**: The OAuth token doesn't include the necessary scopes**Required Permissions:**- `read-repos` - Read access to repositories- `write-repos` - Write access to create repositories- `manage-repos` - Manage repository settings**Steps to fix:**1. **Logout**: Click the logout button in the sidebar2. **Login Again**: Click "Sign in with Hugging Face" again3. **Grant All Permissions**: When the authorization page appears, make sure to check ALL the requested permissions:- β read-repos- β write-repos- β manage-repos4. **Complete Authorization**: Click "Authorize" to complete the login5. **Try Deploying**: Try deploying again**Important:** Make sure you see all three permissions checked on the authorization page before clicking "Authorize".---*Please log in again with full permissions.*""", update_oauth_status(oauth_profile, oauth_token)else:return f"""β **Repository Access Error**Error: {str(repo_error)}This could be due to:- Network connectivity issues- Hugging Face API temporary problems- Account-specific restrictions**Steps to fix:**1. Check your internet connection2. Try logging out and logging back in3. Wait a few minutes and try again4. If the problem persists, check your Hugging Face account settings---*Please try again or contact support if the issue persists.*""", update_oauth_status(oauth_profile, oauth_token)except Exception as token_error:print(f"Debug: Token test failed: {token_error}")580 unmodified lines581582583584585586587588589590591592593594595596597598599600601580 unmodified linesuser_info = test_api.whoami()print(f"Debug: Token test successful - user: {user_info.get('name', 'unknown')}")# Test if user can create repositories by checking their account typetry:# Try to get user info to check account capabilitiesuser_info = test_api.whoami()print(f"Debug: User info: {user_info}")# Check if user has pro account or sufficient permissionsif user_info.get('type') == 'user':print("Debug: User account type confirmed")else:print(f"Debug: User account type: {user_info.get('type', 'unknown')}")except Exception as user_info_error:print(f"Debug: Could not get detailed user info: {user_info_error}")# This is not a critical error, so we continueexcept Exception as token_error:print(f"Debug: Token test failed: {token_error}")
app.py+12-68