hassio-dropbox-upload icon indicating copy to clipboard operation
hassio-dropbox-upload copied to clipboard

Access tokens no longer long lived

Open johnsturgeon opened this issue 3 years ago • 8 comments

After getting 'access denied, token expired' errors constantly for the last few days I checked my access token, and it's gone, along with the option to set the 'expiration policy'

I sent a message to Dropbox and this is their answer:

Hi John,

Dropbox is in the process of switching to only issuing short-lived access tokens (and optional refresh tokens) instead of long-lived access tokens. You can find more information on this migration here.

Apps can still get long-term access by requesting "offline" access though, in which case the app receives a "refresh token" that can be used to retrieve new short-lived access tokens as needed, without further manual user intervention. You can find more information in the OAuth Guide and authorization documentation.

For reference, while the creation of new long-lived access tokens is now deprecated, we don't currently have a plan to disable existing long-lived access tokens. (If that changes, we will of course announce that ahead of time.) That being the case, you can continue using existing long-lived access token(s) without interruption, if you have any. Also, note though that after the change you won't be able to create new long-lived access tokens.

While the change began on September 30th 2021, we're releasing it gradually, so you may not have seen your app(s) affected until now. Once it applies to your app, it would apply regardless of the "Access token expiration" setting for your app, and that setting may no longer be available for your app.

Note that this is something that would need to be implemented by the programmer of the app though, so if you are not the programmer responsible for this integration, you may need to get an update from them to support this.

Regards, Moe

johnsturgeon avatar Mar 19 '22 16:03 johnsturgeon

Interesting. That does look like it could be a problem for everyone soon

d0ugal avatar Mar 19 '22 19:03 d0ugal

Looks like its the case now. Getting errors and only resolution is to replace the access token when it expires.

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
[14:29:23] INFO: Starting Dropbox Upload script...
Unable to refresh access token without                 refresh token and app key
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/app/dropbox_upload/__main__.py", line 60, in <module>
    main(config.DEFAULT_CONFIG)
  File "/app/dropbox_upload/__main__.py", line 36, in main
    dbx.users_get_current_account()
  File "/usr/lib/python3.10/site-packages/dropbox/base.py", line 5263, in users_get_current_account
    r = self.request(
  File "/usr/lib/python3.10/site-packages/dropbox/dropbox.py", line 313, in request
    res = self.request_json_string_with_retry(host,
  File "/usr/lib/python3.10/site-packages/dropbox/dropbox.py", line 463, in request_json_string_with_retry
    return self.request_json_string(host,
  File "/usr/lib/python3.10/site-packages/dropbox/dropbox.py", line 578, in request_json_string
    raise AuthError(request_id, err)
dropbox.exceptions.AuthError: AuthError('cae9a41868444f72a9ca01ce0c17f4a8', AuthError('expired_access_token', None))
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

creedda avatar Nov 05 '22 18:11 creedda

Looks like its the case now. Getting errors and only resolution is to replace the access token when it expires.

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
[14:29:23] INFO: Starting Dropbox Upload script...
Unable to refresh access token without                 refresh token and app key
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/app/dropbox_upload/__main__.py", line 60, in <module>
    main(config.DEFAULT_CONFIG)
  File "/app/dropbox_upload/__main__.py", line 36, in main
    dbx.users_get_current_account()
  File "/usr/lib/python3.10/site-packages/dropbox/base.py", line 5263, in users_get_current_account
    r = self.request(
  File "/usr/lib/python3.10/site-packages/dropbox/dropbox.py", line 313, in request
    res = self.request_json_string_with_retry(host,
  File "/usr/lib/python3.10/site-packages/dropbox/dropbox.py", line 463, in request_json_string_with_retry
    return self.request_json_string(host,
  File "/usr/lib/python3.10/site-packages/dropbox/dropbox.py", line 578, in request_json_string
    raise AuthError(request_id, err)
dropbox.exceptions.AuthError: AuthError('cae9a41868444f72a9ca01ce0c17f4a8', AuthError('expired_access_token', None))
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

Unable to refresh access token without refresh token and app key

This line suggests somewhere in the code its been updated to work with an app key and refresh token. any ideas on how to expose that?

creedda avatar Nov 05 '22 18:11 creedda

I'm facing the same problem here, any luck?

sergiograndini avatar Dec 25 '22 23:12 sergiograndini

I'm facing the same problem here, any luck?

I have switched to the Google drive backup. It's much more than I want in terms of features, but it works well.

I looked a little at the code here, but all the magic is really in the bash script which is managed in a different repository with a different maintainer. And it doesn't appear the bash script is getting maintenance. I would say ideally the Dropbox API logic would get moved into this repository and into python. I'm also hesitant to try and make a PR because I'm not clear the maintainer here is actively maintaining. And I haven't developed HA add-ons yet so I'm not quite sure how to approach it.

wrenoud avatar Dec 26 '22 11:12 wrenoud

There is no bash script here so I think you are confused. This is a pure Python Dropbox project

I am the original author but I don’t use it now. I moved away from the full so or supervised install.

I’d be delighted if somebody would take over and I would help them do that how I can.

d0ugal avatar Dec 26 '22 16:12 d0ugal

@d0ugal I conflated this with the other repo https://github.com/danielwelch/hassio-dropbox-sync. Apologies!

wrenoud avatar Dec 26 '22 16:12 wrenoud

No problem, it’s a bit confusing 😅

d0ugal avatar Dec 26 '22 16:12 d0ugal