You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
talandis
4 years agoNew member | Level 2
Dropbox integration fails with console message: client.getAuthenticationUrl is not a function
My web application has been failing for an unknown amount of time and was only noticed recently. Current behavior is that it is supposed to open a new window and run the following code snippet in that window to connect to dropbox:
var baseaddress = $("#baseaddress").val();
client = new Dropbox.Dropbox({ clientId: dropBoxClientid });
var authUrl = client.getAuthenticationUrl("https://"+baseaddress+'/delivery/download/dropboxredirect.url');
window.location = authUrl;
However I am seeing a console error in the chrome browser dev tools saying:
Uncaught TypeError: client.getAuthenticationUrl is not a function
When inspecting the client variable I do see it being populated and seemingly correctly too. It fetches Dropbox-sdk.min.js from unpkg.com > dropbox@9.6.0/dist correctly which is where it is populating the client variable from. I see getAuthenticationUrl is in a json object in the pulled in JS, but is not a function. Is anyone able to help me figure out what needs to changed in the distro that caused this to no longer work? I was not the original developer who implemented this and I am not sure what version it last worked on unfortunately. Thanks!
The getAuthenticationUrl method was moved under 'auth' in a previous version. You can find an example of using it here.
Looking at your code, you probably mean to do this:
var baseaddress = $("#baseaddress").val(); client = new Dropbox.Dropbox({ clientId: dropBoxClientid }); var authUrl = client.auth.getAuthenticationUrl("https://"+baseaddress+'/delivery/download/dropboxredirect.url') .then((authUrl) => { window.location = authUrl; })
By the way, it's unclear from your message if are you doing so, but we don't recommend always just importing the latest version of the library automatically. In order to avoid major version changes from breaking your app, you should instead import specific versions of the library.
For instance, unpkg has information on specifying particular versions here: https://unpkg.com/
This is because the Dropbox API v2 JavaScript SDK follows "semantic versioning". That means that we will increase the major version number whenever there are breaking changes. In general, you should avoid automatically using the latest version, i.e., including any major version updates, as your code may break when a major update is released. You should only upgrade to the latest major version in your released app once you've had a chance to test it in your app and make any necessary changes.Hope this helps!
- Greg-DBDropbox Staff
The getAuthenticationUrl method was moved under 'auth' in a previous version. You can find an example of using it here.
Looking at your code, you probably mean to do this:
var baseaddress = $("#baseaddress").val(); client = new Dropbox.Dropbox({ clientId: dropBoxClientid }); var authUrl = client.auth.getAuthenticationUrl("https://"+baseaddress+'/delivery/download/dropboxredirect.url') .then((authUrl) => { window.location = authUrl; })
By the way, it's unclear from your message if are you doing so, but we don't recommend always just importing the latest version of the library automatically. In order to avoid major version changes from breaking your app, you should instead import specific versions of the library.
For instance, unpkg has information on specifying particular versions here: https://unpkg.com/
This is because the Dropbox API v2 JavaScript SDK follows "semantic versioning". That means that we will increase the major version number whenever there are breaking changes. In general, you should avoid automatically using the latest version, i.e., including any major version updates, as your code may break when a major update is released. You should only upgrade to the latest major version in your released app once you've had a chance to test it in your app and make any necessary changes.Hope this helps!
- talandisNew member | Level 2
Thank you very much Greg, that worked perfectly! I've also taken your advice to specify the version in the code rather than sticking with the latest.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,894 PostsLatest Activity: 2 hours agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!