Skip to content
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

Add support for Express links in authorize_url for OAuth #648

Merged
merged 1 commit into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions stripe/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ def _set_client_id(params):
)

@staticmethod
def authorize_url(**params):
path = "/oauth/authorize"
def authorize_url(express=False, **params):
if express is False:
path = "/oauth/authorize"
else:
path = "/express/oauth/authorize"

OAuth._set_client_id(params)
if "response_type" not in params:
params["response_type"] = "code"
Expand Down
7 changes: 6 additions & 1 deletion tests/test_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ def test_authorize_url(self, request_mock):
"country": "US",
},
)

o = urlparse(url)
params = parse_qs(o.query)

url_express = stripe.OAuth.authorize_url(
express=True, scope="read_write", state="csrf_token"
)
o_express = urlparse(url_express)

assert o.scheme == "https"
assert o.netloc == "connect.stripe.com"
assert o.path == "/oauth/authorize"
assert o_express.path == "/express/oauth/authorize"

assert params["client_id"] == ["ca_123"]
assert params["scope"] == ["read_write"]
Expand Down