robweber / xbmcbackup

Backup Addon for Kodi
MIT License
107 stars 48 forks source link

Error authorising Dropbox #231

Closed rjclark99 closed 2 months ago

rjclark99 commented 2 months ago

Describe the problem After following the tinyurl link generated by the Backup add on and authorising the app, I copy the key provided, click OK on the authorisation, paste in the provided key and confirm. At this point I get a pop up box with the text 'error authorizing Dropbox'. I initialised the app as described in the documentation, under the Cloud Storage > Dropbox section, including setting the file permissions and creating it as an App Folder.

Upon further inspection into the logs this seems to be the point of failure:

2024-04-18 20:25:29.256 T:330216 debug : script.xbmcbackup-1.6.8: Error: 400 Client Error: Bad Request for url: https://api.dropboxapi.com/oauth2/token

Not super experienced with Kodi so I apologise if I am missing something obvious. Thank you for your work on the add on and taking the time to deal with issues.

Platform and Kodi version MacOS Ventura 12.7.4 Kodi 20.2.0 Also updated Kodi to 21.0 with same results.

Link to Debug Log paste.kodi.tv/aqewiduguh

robweber commented 2 months ago

I deleted all my Dropbox tokens and information to get a clean try at the authorization. My first pass at it succeeded with Dropbox authorizing and my files transferring as expected.

On my second attempt I purposefully entered the wrong authorization code after the QR code portion of the authorization workflow. This resulted in the error you saw.

script.xbmcbackup-1.7.0: Error: 400 Client Error: Bad Request for url: https://api.dropboxapi.com/oauth2/token

It's worth noting that this is an error thrown by the underlying Dropbox API when it cannot fulfill the authorization attempt. I would imagine one of few things is happening.

  1. The authorization code is being copied incorrectly. Make sure it doesn't contain any extra spaces or characters.
  2. Your Dropbox lib version is too old. This should update automatically but the one on my system is 10.3.1
  3. The Backup version is having issues. You could pull the latest version from GitHub. I do have a PR open to update the Kodi repo but not sure when that will get closed.
  4. The Kodi device cannot access the Dropbox API URL.

Hope one of these leads you to a solution.

rjclark99 commented 2 months ago

It seems like a rather odd quirk has occurred with the dropbox api.

After spending much, much longer than I should've on this issue, it appears there was trailing whitespace in the app key which was leading to the authorisation failing. The reason it took so long for me to identify is because I had already checked the pastes of the key and secret and it seemed they had no trailing whitespace, furthermore the authorisation workflow was still functional up until the entering of the validation code. Upon revisiting the key it seems there was an indent preceding the key.

I am far from educated on these matters but it seems dropbox api may strip the input when creating an authorisation link but not when authenticating the credentials, leading to the issue of correctly generating the link but being unable to authenticate.

All of this is to say it was a user error on my behalf and I thank you for your time and assistance in this matter, I'm really grateful for the add on and support!

robweber commented 2 months ago

That's good information to have. I created #232 to remind myself to add some whitespace trimming around those values to help combat this issue in the future. It's an easy thing to miss. Glad you got it working.

rjclark99 commented 2 months ago

It's a peculiar quirk indeed but easily resolved now it's been identified. Thank you again for taking the time to help me diagnose and resolve the issue and hopefully will prevent it in future. Have a great day mate.