MFLUX-WEBUI
MFLUX-WEBUI copied to clipboard
Fix Hugging Face authentication issue
Fix Hugging Face authentication issue
Issue Fixed
Fixed the error 'HfApi' object has no attribute 'set_access_token' which occurred when trying to authenticate with Hugging Face API. This error appeared because the code was using an outdated or incorrect authentication method.
Solution
Updated the login_huggingface function to use the official login() method from the huggingface_hub library instead of trying to directly set an access token on the API object. This approach:
- Uses the officially supported authentication flow
- Properly validates the token via the HF API
- Correctly stores credentials for future use
- Adds git credentials if requested
Implementation Details
- Imported the
loginfunction directly fromhuggingface_hub - Used this function to handle token validation and storage
- Added proper error handling to provide meaningful feedback to users
- Set
add_to_git_credential=Trueto ensure git operations work correctly with protected repositories
Note: My IDE auto-formatted portions of the file. The functional change is limited to the login_huggingface function. The other differences are purely formatting changes that don't affect functionality.
#14 these commits fix that error