-
Notifications
You must be signed in to change notification settings - Fork 457
Update OAuth implementation #323
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
Conversation
c1cb321
to
a0de4e9
Compare
stripe/api_requestor.py
Outdated
except (KeyError, TypeError): | ||
raise error.APIError( | ||
"Invalid response object from API: %r (HTTP response code " | ||
"was %d)" % (rbody, rcode), | ||
rbody, rcode, resp) | ||
|
||
err = None | ||
if isinstance(error_data, basestring): |
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.
Maybe just add a comment here on why we're doing this. I think that the minor structural difference between an OAuth and API error is pretty subtle unless you already know about it.
@ob-stripe Looks good to me! This feels like it strips some complexity out and standardizes on some standard paths, so big +1.
Yeah, in my opinion adding a new module here would be fine.
Good point. I just ran a Splunk query and it doesn't look there's any activity on |
Quick follow up: no requests from stripe-python to |
466a9ee
to
d365b5b
Compare
Alright, I moved the OAuth error classes into their own ptal @brandur-stripe |
Nice! Just out of curiosity, any thoughts on |
9ee9a83
to
4ad315a
Compare
4ad315a
to
e7f467d
Compare
@brandur-stripe Great point, I hadn't thought of this. I agree that This works on Python 2, but apparently causes circular import errors on Python 3 for some reason. This is probably fixable but I'm wary that changing how the imports are done could cause some unforeseen side-effects, so I'd rather play it safe and reverted to using the |
Thanks for looking into it; that sounds good to me. I don't think there's a huge ergonomic different either way, so it seems fine to leave as |
As discussed, released as 1.59.0. |
r? @brandur-stripe
cc @stripe/api-libraries
This PR updates the OAuth implementation to be much closer to the stripe-ruby implementation:
no more dedicated
OAuthRequestor
class. TheAPIRequestor
class can now interpret both API and OAuth errorsdedicated exception classes for each OAuth error type
This is technically a breaking change, but we never documented this feature (and won't until ~all libraries support it) so I don't think this necessarily warrants a major version bump.
The one thing I'm not happy about is the
OAuthInvalidRequestError
class name, to differentiate it from the existingInvalidRequestError
class. I think it might be worth it moving all the OAuth errors in a different module, e.g.oauth_error
, so they have their own namespace and we can reuse theInvalidRequestError
class name.wdyt?