Skip to content

Commit

Permalink
Merge pull request #719 from stripe/brandur-support-express-authorize
Browse files Browse the repository at this point in the history
Generate OAuth authorize URLs for express accounts
  • Loading branch information
brandur-stripe authored Jan 2, 2019
2 parents 6f81c90 + 403be3b commit 365759e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/stripe/oauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ def self.get_client_id(params = {})
def self.authorize_url(params = {}, opts = {})
base = opts[:connect_base] || Stripe.connect_base

path = "/oauth/authorize"
path = "/express" + path if opts[:express]

params[:client_id] = get_client_id(params)
params[:response_type] ||= "code"
query = Util.encode_parameters(params)

"#{base}/oauth/authorize?#{query}"
"#{base}#{path}?#{query}"
end

def self.token(params = {}, opts = {})
Expand Down
9 changes: 9 additions & 0 deletions test/stripe/oauth_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ class OAuthTest < Test::Unit::TestCase
assert_equal(["https://example.com/profile/test"], params["stripe_user[url]"])
assert_equal(["US"], params["stripe_user[country]"])
end

should "optionally return an express path" do
uri_str = OAuth.authorize_url({}, express: true)

uri = URI.parse(uri_str)
assert_equal("https", uri.scheme)
assert_equal("connect.stripe.com", uri.host)
assert_equal("/express/oauth/authorize", uri.path)
end
end

context ".token" do
Expand Down

0 comments on commit 365759e

Please sign in to comment.