How do I authenticate a Dropbox app and use the API without leaving the webpage?

12,035

Solution 1

The Dropbox API does currently require that the authorization be processed with OAuth via the Dropbox site. You can use the 'oauth_callback' parameter to redirect the user back to your site after authorization. Docs here: https://www.dropbox.com/developers/reference/api#authorize

You can even use this within a single tab for the whole process (which is what StackOverflow with Google's login seems to do.) That is, redirect the user's current page to the authorize page, and use 'oauth_callback' param with the necessary action/information to return to your site and indicate the user is coming back from authorization.

Solution 2

Use an iframe.

open the Oauth in an iframe. set the redirect to iframe_done.html

when iframe_done.html loads up, it will be the same domain as your main page, so it can communicate outside of the iframe, just get the key you just received and pass it up to the parent, who will use the key and close the iframe, giving the impression it all happened there.

Share:
12,035
efficiencyIsBliss
Author by

efficiencyIsBliss

Junior at Colgate University. Primarily interested in Algorithms, data structures, math and such. Largely a Java programmer.

Updated on June 06, 2022

Comments

  • efficiencyIsBliss
    efficiencyIsBliss almost 2 years

    I need users to grant my app permission to access their Dropbox, but I would very much like for them to not have to leave my website and then come back. The authentication API that I know of requires that the user be logged into their Dropbox account, and that they authenticate the app on the Dropbox website.

    Is there some way around this?

    --Edit--

    So I know that we can use Google/Facebook's authentication API such that the user is prompted to allow/deny the app within the same window (SO does this). If we can do something of this sort with the Dropbox API, that would be awesome.

    Thanks!

  • efficiencyIsBliss
    efficiencyIsBliss about 12 years
    Is there any open source project that implements Dropbox's API? I want to see an example that authenticates with Dropbox using OAuth.
  • Greg
    Greg about 12 years
    I'm sure there are open source projects using the Dropbox API, but I don't know of any off-hand. There are examples in each official SDK though: dropbox.com/developers/reference/sdk
  • xchg.ca
    xchg.ca over 11 years
    I'm curious how native Android Dropbox app does it, when you login it just let you in, there is no redirect !?
  • ddewaele
    ddewaele over 11 years
    Native Android Dropbox app has access to internal APIs that cannot be used by third party apps.