Skip to content

Commit 4186aa5

Browse files
committed
Don't include incoming querystring in Dropbox Business callback_url
Unlike most providers, the Dropbox Business (and Dropbox consumer) API require the callback_url to exactly match what is configured in their web UI, **including any querystring values**. By default, OmniAuth appends any incoming querystrings to the callback_url being sent the the provider. This means that if your app begins auths with something like: /auth/dropbox_oauth2?auth_version=v2, Your callback_url becomes: /auth/dropbox_oauth2/callback?auth_version=v2 This doesn't exact match Dropbox Business' overly strict requirements for this URL: /auth/dropbox_oauth2/callback The fix is for this provider to override callback_url so that the querystring is not appended automatically. There is a long-going disucssion to see whether this should be fixed in omniauth-oauth2 or within each affected provider strategy: omniauth/omniauth-oauth2#93 It's not super clear, but the consensus seems to be that this behavior should be accounted for in the strategy. Here's the similar issue for Dropbox (consumer): icoretech/omniauth-dropbox2#2 Unmerged PR in the consumer library: icoretech/omniauth-dropbox2#2
1 parent 18db510 commit 4186aa5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/omniauth/strategies/dropbox_oauth2.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ def callback_url
4444
if @authorization_code_from_signed_request
4545
''
4646
else
47-
options[:callback_url] || super
47+
# Override to remove query_string. Dropbox will verify that the
48+
# redirect_uri provided in the token request matches the one used for
49+
# the authorize request, and using the query string will cause
50+
# redirect_uri mismatch errors.
51+
# OmniAuth issue: https://github.com/omniauth/omniauth-oauth2/issues/93
52+
# Similar: https://github.com/icoretech/omniauth-dropbox2/pull/2/files
53+
full_host + script_name + callback_path
4854
end
4955
end
5056
end

0 commit comments

Comments
 (0)