cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted

Redirect URI with variable loopback port

Explorer | Level 3

Is there any way to register an OAuth2 redirect URI that will support using an unreserved (random) port over loopback/localhost?  For desktop applications that might not be installed system-wide (e.g., portable installs), app-declared custom URI scheme redirection and app-claimed HTTPS URI redirection aren't available, and creating a short-lived local HTTP server works well for other OAuth2 services.  Dropbox's URI matching appears to require a matching port too though.  Do we need to just register ~50,000 URIs for all the different ports?  Is there a better alternative?

 

 

1 Accepted Solution

Accepted Solutions
Highlighted

Re: Redirect URI with variable loopback port

Dropboxer
Dropboxer

I'm afraid I don't have a great solution for you, as OAuth 2 redirect URIs for the Dropbox API are required to be pre-registered exactly. I'll be sure to pass this along as feedback though.


One thing you may be able to do instead is to use one static redirect URI but encode the necessary information in the 'state' parameter, and decode it as necessary after the redirect back to your app, to handle it as necessary:


https://www.dropbox.com/developers/documentation/http/documentation#authorization

 

Alternatively, you could forgo using a redirect URI entirely. With the "code" flow, you can omit redirect_uri and have the user copy and paste the code manually. (Or, for the "token" flow, you can use https://www.dropbox.com/1/oauth2/display_token as the redirect URI and have the user copy and paste the access token.)

View solution in original post

6 Replies 6
Highlighted

Re: Redirect URI with variable loopback port

Dropboxer
Dropboxer

I'm afraid I don't have a great solution for you, as OAuth 2 redirect URIs for the Dropbox API are required to be pre-registered exactly. I'll be sure to pass this along as feedback though.


One thing you may be able to do instead is to use one static redirect URI but encode the necessary information in the 'state' parameter, and decode it as necessary after the redirect back to your app, to handle it as necessary:


https://www.dropbox.com/developers/documentation/http/documentation#authorization

 

Alternatively, you could forgo using a redirect URI entirely. With the "code" flow, you can omit redirect_uri and have the user copy and paste the code manually. (Or, for the "token" flow, you can use https://www.dropbox.com/1/oauth2/display_token as the redirect URI and have the user copy and paste the access token.)

View solution in original post

Highlighted

Re: Redirect URI with variable loopback port

Explorer | Level 3

Thanks Greg.  I considered using a static redirect URI like you suggested, but that would require redirecting to our own website before redirecting to localhost for the real processing.  Since we're a desktop app, I'd rather we not be involved, especially since corporate firewalls might be set up to allow access to Dropbox but not our own site.

 

I've gone with the code flow for now and it's working, but I do hope the localhost URI matching is made more flexible in the future.

Highlighted

Re: Redirect URI with variable loopback port

Explorer | Level 4
I'd like to upvote the ability to have an arbitrary port in the redirect_uri. This could be allowed only for localhost.

Without this, I don't see how we can move from doing oauth in an embedded browser window to using the system default browser as is recommended. It isn't possible to know what port will be free on a client system so that needs to be done at runtime.

If you look at the google oauth examples (https://github.com/googlesamples/oauth-apps-for-windows) they use a random port. From all of the Dropbox examples I've seen you use a fixed port which is inevitably going to fail on someones machine.

Skipping the redirect URI and having the user cut and paste the code is a non-starter for us. Our users would be very unhappy.
Highlighted

Re: Redirect URI with variable loopback port

Dropboxer
Dropboxer
Thanks for the feedback! I'll send it along to the team.
Highlighted

Re: Redirect URI with variable loopback port

New member | Level 2
New member | Level 2

I'm encountering the same problem, I tested many other sources like Google, Salesforce, Twitter, they all support variable port for localhost. This is very useful when changing embedded browser to system browser.

Highlighted

Re: Redirect URI with variable loopback port

Dropboxer
Dropboxer

@qedi Thanks for the feedback!

Polls
Do you know how to organize your files and folders?
We have created a guide on folder best practice, so you can get organized now check it out here.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?