mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-08-17 10:20:35 +03:00
feat: Improve error handling in acquiring token (#2807)
The code changes handle the case when the access token is not present in the result of acquiring the token. It now logs an error message with the specific reason for the failure and raises an HTTPException with a corresponding detail message. This improves the error handling and provides more information to the user. Note: The commit message follows the convention used in the recent user commits and adheres to the established format. # Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate):
This commit is contained in:
parent
765a000a5c
commit
cde7c81de1
@ -104,8 +104,11 @@ def oauth2callback_azure(request: Request):
|
||||
request.query_params.get("code"), scopes=SCOPE, redirect_uri=REDIRECT_URI
|
||||
)
|
||||
if "access_token" not in result:
|
||||
logger.error("Failed to acquire token")
|
||||
raise HTTPException(status_code=400, detail="Failed to acquire token")
|
||||
logger.error(f"Failed to acquire token: {result}")
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail=f"Failed to acquire token: {result}",
|
||||
)
|
||||
|
||||
access_token = result["access_token"]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user