-
-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding OAuth revoke and introspect endpoints #261
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #261 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 7 7
Lines 304 323 +19
=========================================
+ Hits 304 323 +19 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall, just need some clarification on the Authorization header.
…ublic integrations. Docs updates to come
I think some documentation updates would be great, but I will wait for any feedback on codebase changes before doing that so I don't waste anytime documenting unwanted changes :-)! The tests are a bit annoying since the developer effectively has to burn two tokens, but that was the only strategy I found to work. Let me know if any changes should be made!! Also if you have any general best practices for this codebase, or PRs that I am not following, please let me know 😄 |
# Any oauth errors throw this exact error syntax, so handle them as so | ||
if "code" not in body and body.get("error") == "invalid_client": | ||
raise APIResponseError( | ||
response, body["error"], APIErrorCode("unauthorized") | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is weird, how does the JS SDK handle this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments.
Tests are failing. :) Why do you say two tokens have to be burnt? I only see one revoke here. |
One token has to be intercepted to be used in the generate token endpoint, and then another in the introspect and revoke. So I guess only the revoke token has to be burned, but the developer has to create a code and a token. I was thinking one token could be used, but then the generate token would have to be run, and the token would have to be set on the fly, before the introspect and revoke test could be run, which I am not sure is desirable behavior. Let me know! Looks like this may be the reason the tests are failing in Python 3.9 and lower. Could this possibly be the reason? If so, do you have any suggestions? If not, let me know and I can investigate further. |
…for private and public integrations. Updated cassettes will come when all proposed changes are complete
notion_client/client.py
Outdated
@@ -102,11 +107,19 @@ def _build_request( | |||
path: str, | |||
query: Optional[Dict[Any, Any]] = None, | |||
body: Optional[Dict[Any, Any]] = None, | |||
auth: Optional[str] = None, | |||
auth: Optional[Union[str, Dict[str, str]]] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use a TypedDict :P
(and drop support for Python 3.7 since it has been implemented in 3.8)
Not sure if this will remove this version support in the CI. I have a feeling it won't but should fix the tox tests locally
Let me know what you think of the current changes since your last comments. If those look better, I will fix the rest of the pending changes :-). |
Yeah it's going in the right direction, keep up the good work! You've already done more than I thought necessary when I opened #261. Sorry if the PR feels a bit tedious, this library is vastly used in the wild so the last thing I want is more work fixing things down the line. :) |
Removes Python 3.7 from documentation and Github Actions
…h better authorization information
No worries, apologies if it has taken a number of iterations to produce high quality code! I think I have resolved all of your reviews, besides the error handling in the case of the 401 response. To Clarify why I am confused on this: If I do nothing, an APIResponseError is not raised, and the error is instead raised as an HTTPResponseError. This is because the current code checks for the string
Let me know what you think of those options, or if you have an entirely different idea on how to solve that :-). Additionally here are the steps I have to take in order to create new cassettes for the tests. This will explain why I have to generate two token. I don't think there is a way to avoid this because the token would have to be generated on the fly and the environment variable would have to be set from within the tests. I don't think that is a solid solution because the tests shouldn't have to be executed in a definitive order like that.
I understand this is a bit of a clunky and hacky solution, but it is the best I could think of right now. If you have a better way to go about this, please let me know! Otherwise I will update the developer docs to include these steps. Apologies for the wordy comment 😅 |
oops, ugh
As described in Issue #260,
This PR adds that functionality to this SDK.