derrix060 / onedriveClient

A Microsoft OneDrive and OneDrive for Business client for Linux, written in Python3.
MIT License
65 stars 10 forks source link

Exception: Invalid grant #10

Closed daviddavo closed 6 years ago

daviddavo commented 6 years ago
pi@bpi-iot-ros-ai:~ $ onedrived start --debug
Starting onedrived ... OK
Please enter password for encrypted keyring: 
session loaded
[2017-12-18 09:38:33,772] DEBUG: MainThread: Starting new HTTPS connection (1): login.microsoftonline.com
[2017-12-18 09:38:34,534] DEBUG: MainThread: https://login.microsoftonline.com:443 "POST /common/oauth2/token HTTP/1.1" 200 2610
session refreshed
[2017-12-18 09:38:35,352] DEBUG: MainThread: Starting new HTTPS connection (1): ucomplutense-my.sharepoint.com
[2017-12-18 09:38:35,920] DEBUG: MainThread: https://ucomplutense-my.sharepoint.com:443 "GET /_api/v2.0/drives HTTP/1.1" 200 None
[2017-12-18 09:38:36,036] DEBUG: MainThread: Refreshing repository session.
[2017-12-18 09:38:36,060] DEBUG: MainThread: Starting new HTTPS connection (1): login.microsoftonline.com
[2017-12-18 09:38:36,816] DEBUG: MainThread: https://login.microsoftonline.com:443 "POST /common/oauth2/token HTTP/1.1" 200 2610
session refreshed
expires in: 3598.3480157852173
[2017-12-18 09:38:37,513] INFO: MainThread: Session for account 01DJ6EXAF6Y2GOVW7725BZO354PWSELRRZ will expire in 3598 seconds.
expires in: 3598.3444871902466
[2017-12-18 09:38:37,516] DEBUG: MainThread: Will refresh session in 3478 seconds.
[2017-12-18 09:38:38,206] DEBUG: MainThread: Starting new HTTPS connection (1): login.live.com
[2017-12-18 09:38:39,144] DEBUG: MainThread: https://login.live.com:443 "POST /oauth20_token.srf HTTP/1.1" 400 210
Traceback (most recent call last):
  File "/usr/local/bin/onedrived", line 11, in <module>
    load_entry_point('onedrived==2.0.0', 'console_scripts', 'onedrived')()
  File "/usr/local/lib/python3.4/dist-packages/click-6.6-py3.4.egg/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click-6.6-py3.4.egg/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.4/dist-packages/click-6.6-py3.4.egg/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.4/dist-packages/click-6.6-py3.4.egg/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.4/dist-packages/click-6.6-py3.4.egg/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/daemonocle-1.0.1-py3.4.egg/daemonocle/cli.py", line 57, in subcommand
  File "/usr/local/lib/python3.4/dist-packages/daemonocle-1.0.1-py3.4.egg/daemonocle/core.py", line 608, in do_action
  File "/usr/local/lib/python3.4/dist-packages/daemonocle-1.0.1-py3.4.egg/daemonocle/core.py", line 477, in start
  File "/usr/local/lib/python3.4/dist-packages/daemonocle-1.0.1-py3.4.egg/daemonocle/core.py", line 399, in _run
  File "/usr/local/lib/python3.4/dist-packages/onedrived/od_main.py", line 195, in main
    all_accounts = get_repo_table(context)
  File "/usr/local/lib/python3.4/dist-packages/onedrived/od_main.py", line 101, in get_repo_table
    authenticator, drives = get_authenticator_and_drives(ctx, account_id)
  File "/usr/local/lib/python3.4/dist-packages/onedrived/od_auth.py", line 42, in get_authenticator_and_drives
    drives = authenticator.client.drives.get()
  File "/usr/local/lib/python3.4/dist-packages/onedrivesdk/request/drives_collection.py", line 118, in get
    return self.request().get()
  File "/usr/local/lib/python3.4/dist-packages/onedrivesdk/request/drives_collection.py", line 38, in get
    collection_response = DrivesCollectionResponse(json.loads(self.send().content))
  File "/usr/local/lib/python3.4/dist-packages/onedrivesdk/request_base.py", line 132, in send
    self._client.auth_provider.authenticate_request(self)
  File "/usr/local/lib/python3.4/dist-packages/onedrivesdk/auth_provider.py", line 232, in authenticate_request
    self.refresh_token()
  File "/usr/local/lib/python3.4/dist-packages/onedrivesdk/auth_provider.py", line 261, in refresh_token
    data=params)
  File "/usr/local/lib/python3.4/dist-packages/onedrivesdk/http_provider.py", line 71, in send
    custom_response = HttpResponse(response.status_code, response.headers, response.text)
  File "/usr/local/lib/python3.4/dist-packages/onedrivesdk/http_response.py", line 61, in __init__
    raise Exception(str(message["error"]))
Exception: invalid_grant
[2017-12-18 09:38:39,263] DEBUG: Dummy-1: Closing database "/home/pi/.config/onedrived/items_b!_EiJPDydBkqU9sAVU66liNsHLNtiyWxPu9itOHoimhEtGHvbwi1PTrnuIoBhJlgJ.sqlite3".
All children are gone. Parent is exiting...
derrix060 commented 6 years ago

Have you configured the settings inside any virtual enviroment? I only could reproduce it when I install inside a virtual env.

ByteCommander commented 6 years ago

I just encountered this same issue as well, out of the blue. I don't know of any changes that could have been made to the Python installation since I started onedrived successfully last time. I even tried to make sure it does not run in any venv by calling Ubuntu 16.04's preinstalled system Python executable directly, but no difference.

Can this issue be reopened and possibly fixed, please? Or are there at least any workarounds to get it running again?

$ /usr/bin/python3.5 /usr/local/bin/onedrived start --debug
Starting onedrived ... OK
[2018-09-03 01:38:49,568] DEBUG: MainThread: Starting new HTTPS connection (1): login.microsoftonline.com
[2018-09-03 01:38:49,958] DEBUG: MainThread: https://login.microsoftonline.com:443 "POST /common/oauth2/token HTTP/1.1" 400 605
Traceback (most recent call last):
  File "/usr/local/bin/onedrived", line 11, in <module>
    load_entry_point('onedrived==2.0.0', 'console_scripts', 'onedrived')()
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/daemonocle/cli.py", line 57, in subcommand
    daemon.do_action(name)
  File "/usr/local/lib/python3.5/dist-packages/daemonocle/core.py", line 608, in do_action
    func()
  File "/usr/local/lib/python3.5/dist-packages/daemonocle/core.py", line 477, in start
    self._run()
  File "/usr/local/lib/python3.5/dist-packages/daemonocle/core.py", line 399, in _run
    self.worker()
  File "/usr/local/lib/python3.5/dist-packages/onedrived/od_main.py", line 195, in main
    all_accounts = get_repo_table(context)
  File "/usr/local/lib/python3.5/dist-packages/onedrived/od_main.py", line 101, in get_repo_table
    authenticator, drives = get_authenticator_and_drives(ctx, account_id)
  File "/usr/local/lib/python3.5/dist-packages/onedrived/od_auth.py", line 45, in get_authenticator_and_drives
    authenticator.refresh_session(account_id)
  File "/usr/local/lib/python3.5/dist-packages/onedrived/od_auth.py", line 188, in refresh_session
    self.client.auth_provider.refresh_token()
  File "/usr/local/lib/python3.5/dist-packages/onedrivesdk/auth_provider.py", line 261, in refresh_token
    data=params)
  File "/usr/local/lib/python3.5/dist-packages/onedrivesdk/http_provider.py", line 71, in send
    custom_response = HttpResponse(response.status_code, response.headers, response.text)
  File "/usr/local/lib/python3.5/dist-packages/onedrivesdk/http_response.py", line 61, in __init__
    raise Exception(str(message["error"]))
Exception: invalid_grant
[2018-09-03 01:38:50,182] DEBUG: Dummy-1: Close <_UnixSelectorEventLoop running=False closed=False debug=True>
All children are gone. Parent is exiting...
derrix060 commented 6 years ago

@ByteCommander Try with the new version 2.0.1. I believe it should work now. Unfortunately, you will have to configure your account again, because I add one more scope (offline access) and it needs to be validated on Microsoft.

derrix060 commented 6 years ago

@daviddavo can you please try too?

derrix060 commented 6 years ago

NOTE: now is possible to run this package inside a virtualenv. I just test it here, and is working...

daviddavo commented 6 years ago
pi@bpi-iot-ros-ai:~ $ onedrived start --debug
Starting onedrived ... OK
Please enter password for encrypted keyring: 
[2018-09-14 18:46:49,024] DEBUG: MainThread: Starting new HTTPS connection (1): login.microsoftonline.com
[2018-09-14 18:46:49,820] DEBUG: MainThread: https://login.microsoftonline.com:443 "POST /common/oauth2/token HTTP/1.1" 200 2737
[2018-09-14 18:46:50,925] DEBUG: MainThread: Starting new HTTPS connection (1): ucomplutense-my.sharepoint.com
[2018-09-14 18:46:51,675] DEBUG: MainThread: https://ucomplutense-my.sharepoint.com:443 "GET /_api/v2.0/drives HTTP/1.1" 200 None
[2018-09-14 18:46:51,843] DEBUG: MainThread: Refreshing repository session.
[2018-09-14 18:46:51,856] DEBUG: MainThread: Starting new HTTPS connection (1): login.microsoftonline.com
[2018-09-14 18:46:52,426] DEBUG: MainThread: https://login.microsoftonline.com:443 "POST /common/oauth2/token HTTP/1.1" 200 2732
[2018-09-14 18:46:53,397] INFO: MainThread: Session for account 01DJ6EXAF6Y2GOVW7725BZO354PWSELRRZ will expire in 3598 seconds.
[2018-09-14 18:46:53,399] DEBUG: MainThread: Will refresh session in 3478 seconds.
[2018-09-14 18:46:54,153] INFO: MainThread: Sweeping onedrived temporary files from local repositories.
[2018-09-14 18:46:55,592] DEBUG: Worker-0: Started.
[2018-09-14 18:46:55,598] DEBUG: Worker-1: Started.
[2018-09-14 18:46:57,628] CRITICAL: MainThread: Error initializing webhook: Did not find API interface of ngrok.
[2018-09-14 18:46:57,649] INFO: MainThread: Shutting down. Code: Exiting with message: None.
[2018-09-14 18:46:57,720] INFO: Worker-0: Stopped.
[2018-09-14 18:46:57,723] INFO: Worker-1: Stopped.
[2018-09-14 18:46:57,740] INFO: MainThread: Shut down complete.
[2018-09-14 18:46:57,764] DEBUG: Dummy-1: Closing database "/home/pi/.config/onedrived/items_b!_EiJPDydBkqU9sAVU66liNsHLNtiyWxPu9itOHoimhEtGHvbwi1PTrnuIoBhJlgJ.sqlite3".

ngrok is installed on /usr/local/bin/ngrok

derrix060 commented 6 years ago

That's cool, looks like this issue has been fixed. Can you open another issue about the ngrok? I think I know what's going on...