0

I am able to perform the functionalities of Authentication, receiving the Access Token and upload and download of files from Dropbox using this SDK. However i want to be able to implement this functionality on a local html page. Basically, i used the Dropbox SDK at the script and im going by the example given

<script src="https://unpkg.com/dropbox/dist/Dropbox-sdk.min.js"></script>

For authentication the steps are to provide a client ID and a redirect URI, in the example they have used a static client ID and we need to pass the redirect URI in the dbx.getAuthenticationUrl function, this sets the redirect uri as the href of a link which is basically the authentication link which goes to the page where the user logs and is redirected to the redirect URI provided, where we take the access token to be used for further operations. On trying multiple redirect URI's i am getting the same error for which ever URI i provide

More details for developers

Invalid redirect_uri: "http://localhost/redirect.html": It must exactly match one of the redirect URIs you've pre-configured for your app (including the path).

This file is valid, but the message persists. Do i need to redirect to any other URL, i have tried a URL of a file on a server which is correct as the file opens when i try that url in the browser. In the example they redirect to the same URI http://localhost:8080, NO OTHER, even the port number, if i change the port number it shows the same error and only works at 8080. What am i missing? Is there any other place where the url is specified? I am only specifying it like in the example html file

var dbx = new Dropbox({ clientId: CLIENT_ID });
var authUrl = dbx.getAuthenticationUrl('http://localhost:8080/auth');
BrstDev
  • 61
  • 10
  • The error message is referring to the requirement of pre-registering your redirect URI(s) on the App Console: https://www.dropbox.com/developers/apps Make sure you've done that first. – Greg Nov 30 '16 at 17:11
  • Question, where is this example SDK's redirect URI registered, why wont URI's other than http://localhost:8080 work? Also, can it not function like a simple interface where any user can be authenticated and can upload stuff directly to their dropbox? – BrstDev Dec 01 '16 at 05:37
  • OAuth 2 redirect URIs for the sample apps in the SDKs need to be pre-registered just like any other. And yes, the Dropbox API is designed such that each user links their own account to interact with their own files. – Greg Dec 01 '16 at 17:31
  • @Greg so where do i find this sample app that is pre-registered in the SDK, where do i change it do it actually redirects there and does not give the 'Invalid redirect_uri' error. I need my app to function independently, so that the redirect URI is one which i will be in control of so i can show to anybody that they are authenticated and logged in and now they can upload content from this app here without going to Dropbox – BrstDev Dec 12 '16 at 08:21
  • The sample apps are included with the SDK here: https://github.com/dropbox/dropbox-sdk-js/tree/master/examples Note that these are not pre-registered for you, but rather that you should register the necessary OAuth 2 redirect URI, like you would the real one, for your app on its page on the App Console: https://www.dropbox.com/developers/apps – Greg Dec 12 '16 at 18:47

0 Answers0