Closed wangshuai-wuhan closed 2 months ago
Hey there, @wangshuai-wuhan! Nice to see you back with us. Hope you're doing well amidst these tech hiccups!
Based on the error logs you've provided, it seems like the issue is related to the Notion API authentication. The "401 Client Error: Unauthorized" error typically occurs when the API token (also known as the integration token) is missing, incorrect, or has been revoked, leading to unauthorized access attempts to the Notion API.
To resolve this issue, you can follow these steps:
Verify the Integration Token: Ensure that the notion_integration_token
you've provided in your integration details is correct. This token should be the one generated when you created the integration on Notion's side. You can find or regenerate this token in your Notion integration settings.
Update the Token in Your Application: If the token has been updated or was incorrect, make sure to update it in the place where your application stores or retrieves the Notion credentials. In the provided code, this would involve ensuring that the correct token is set in the self.integration_details.settings
dictionary under the key "notion_integration_token"
.
Check Token Permissions: Ensure that the integration token has the necessary permissions to access the resources you're trying to access with the API. This includes permissions to read or write pages, depending on what your application is doing.
Review API Version: The code specifies the Notion API version as "Notion-Version": "2022-06-28"
. Ensure that this version is still supported and hasn't been deprecated. If a new version is available, consider updating to it after reviewing any potential changes that could affect your application.
Here's the relevant part of your code that sets up the authorization header, which is where you should ensure the correct token is being used:
def _headers(self) -> dict[str, str]:
"""Get the headers for the Notion API"""
return {
"Authorization": f'Bearer {self.credentials["notion_integration_token"]}',
"Content-Type": "application/json",
"Notion-Version": "2022-06-28",
}
Ensure that self.credentials["notion_integration_token"]
contains the correct and valid token. If you've verified the token and are still encountering issues, you may need to regenerate the token from the Notion integration settings and update your application accordingly.
For more details, you can refer to the NotionConnector class in the quivr repository.
I hope this helps! If you have any other questions or need further clarification, feel free to ask.
Thanks for your contributions, we'll be closing this issue as it has gone stale. Feel free to reopen if you'd like to continue the discussion.
What happened?
@StanGirard the quivr can answer a question from source now. but waiting a minitue, docker apper an 401 Client Error: Unauthorized for url: https://api.notion.com/v1/search。Will this be a problem for next question , like repeating cousume huge tokens. it‘ takes big price to use gpt 4。
i put quivr on wsl in window 11 and have to ues a vpn proxy fro opneai api . being not a porgramer ,i feel At a loss to meet those errors during many trials, i would like to subscribe your quivr app , but it still appear network Error. I am on the edge of giving up.
Relevant log output
Twitter / LinkedIn details
No response