cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

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: 

Dropbox integration fails with console message: client.getAuthenticationUrl is not a function

Dropbox integration fails with console message: client.getAuthenticationUrl is not a function

talandis
New member | Level 2
Go to solution

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!

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

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!

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution

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!

talandis
New member | Level 2
Go to solution

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. 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    talandis New member | Level 2
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?