Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"No Drive associated with account" #32

Open
ghost opened this issue Nov 20, 2018 · 26 comments
Open

"No Drive associated with account" #32

ghost opened this issue Nov 20, 2018 · 26 comments

Comments

@ghost
Copy link

ghost commented Nov 20, 2018

Having some trouble with syncing with OneDrive For Business. It was working fine, but stopped a few days ago, not sure exactly when (was OK on 26 Oct, not on 19 Nov). This is the error I now see in the log:

[2018-11-20 17:11:49,961] INFO: MainThread: No Drive associated with account "[email protected]" (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX).

I've upgraded to the latest onedrive-client to no avail.

I've set up and onedrive-client-pref account list correctly shows my account. However, onedrive-client-pref drive list gives me no drives:

Reading drives information from OneDrive server...

All available Drives of authorized accounts:

#    Account Email    Drive ID    Type    Quota    Status
---  ---------------  ----------  ------  -------  --------

Drives that have been set up:
 No Drive has been setup with onedrive_client.

I still have OneDrive on my account, and my Windows machine and Android app are able to connect to to it fine.

Any assistance appreciated!

@derrix060
Copy link
Owner

Thank you for the feedback. I think the problem is that we are looking to another directory to find the associated drives because we renamed the package name.

This should be an easy fix, and I'll create a commit in a few hours (after I finish my work).

@derrix060 derrix060 self-assigned this Nov 20, 2018
@derrix060 derrix060 added the bug label Nov 20, 2018
@derrix060
Copy link
Owner

derrix060 commented Nov 21, 2018

FYI: I'm debugging here and thinking what is the best way to fix this issue.

The problem is because the name change, there are a couple of things that have broken:

  • config.json (where it's store the accounts, drivers, etc)
  • keyring: The password now is different, so is not possible to authenticate and refresh a session.

Here are some options:

  • rollback the commit: this can break who are using the latest version;
  • support both: This will make the code very ugly with a lot of hacks.
  • Force everyone to use the latest version only. This is a breaking change, and I need to test rather is possible to create a new driver pointing to the same dir, without loose any data or having to re-sync everything from scratch. I will try first to manually move some files around and if it works I will create a manual step-by-step how to do it

@derrix060
Copy link
Owner

derrix060 commented Nov 21, 2018

Ok, so probably what I said before is not the root cause. Debugging the application looks like when querying https://[domain]-my.sharepoint.com/_api/v2.0/drives it's returning nothing!! I will really need to change the api to use the supported Graph (#26)!

@ndit-dev
Copy link

There is no workaround for this atm?

@derrix060
Copy link
Owner

@ndit-dev not that I'm aware of. That's the problem of relying on Microsoft, they can change their API without telling anyone...

BTW if you find a workaround, please let me know

@ndit-dev
Copy link

ndit-dev commented Dec 3, 2018

I don't fully understand the solution here. But https://github.com/abraunegg/onedrive seems to be on track.
Look at abraunegg/onedrive#248 & abraunegg/onedrive#264
as well as https://github.com/abraunegg/onedrive/blob/master/README.Office365.md

In the end I got it working (with abraunegg's OneDrive) with the drive ID that looks like b!****M**0****X**1****Y**T****T**K****l**k****k**5**_PQ****hS_**YK if that gives you any kind of lead

@derrix060
Copy link
Owner

@ndit-dev I will take a look into the links that you gave me later. In this meantime, can you test the solution from #26? It should work

@derrix060 derrix060 assigned ghost and unassigned derrix060 Dec 6, 2018
@derrix060
Copy link
Owner

@ndit-dev The project that you sent is using the graph-api. Please check the changes that I've made on #26. If it works, I will merge into master.

@bastianbowe2000
Copy link

@derrix060 I'm willing to try out the changes. But I don't know where the changes are. #26 doesn't seem to be a onedriveClient.

@derrix060
Copy link
Owner

derrix060 commented Dec 13, 2018

@bastianbowe2000 Sorry about that, I was not so clear.

Checkout this branch https://github.com/derrix060/onedriveClient/tree/%2326-use-ms-graph-api
and remember to install the graph-sdk from the submodule:

git clone https://github.com/derrix060/onedriveClient.git
cd onedriveClient
git checkout "#26-use-ms-graph-api"
pip3 install .
pip3 installl graph-sdk-python/

@baztian
Copy link

baztian commented Dec 15, 2018

I'm getting

$ onedrive-client-pref account add
Traceback (most recent call last):
  File "/home/me/Software/onedrive-client/bin/onedrive-client-pref", line 9, in <module>
    load_entry_point('onedriveClient==2.0.1', 'console_scripts', 'onedrive-client-pref')()
  File "/home/me/Software/onedrive-client/lib/python3.5/site-packages/pkg_resources/__init__.py", line 542, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/home/me/Software/onedrive-client/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2569, in load_entry_point
    return ep.load()
  File "/home/me/Software/onedrive-client/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2229, in load
    return self.resolve()
  File "/home/me/Software/onedrive-client/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2235, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/home/me/Software/onedrive-client/lib/python3.5/site-packages/onedrive_client/od_pref.py", line 13, in <module>
    from onedrive_client import mkdir, get_resource, od_i18n, od_auth
  File "/home/me/Software/onedrive-client/lib/python3.5/site-packages/onedrive_client/od_auth.py", line 120
    f"Failed to read user profile:{data['error']['message']}")
                                                            ^
SyntaxError: invalid syntax

@baztian
Copy link

baztian commented Dec 15, 2018

Fixing the bug in od_auth.py (removing the leading f char) makes the operation

onedrive-client-pref account add

work for my onedrive business account. I can add the drive. Running the client doesn't really work though.

$ onedrive-client start --debug
Starting onedrive-client ... OK
[2018-12-15 22:06:28,315] DEBUG: MainThread: Starting new HTTPS connection (1): login.microsoftonline.com
[2018-12-15 22:06:28,650] DEBUG: MainThread: https://login.microsoftonline.com:443 "POST /common/oauth2/v2.0/token HTTP/1.1" 200 3219
[2018-12-15 22:06:28,705] DEBUG: MainThread: Starting new HTTPS connection (1): graph.microsoft.com
[2018-12-15 22:06:29,142] DEBUG: MainThread: https://graph.microsoft.com:443 "GET /v1.0/me/drives HTTP/1.1" 200 None
[2018-12-15 22:06:29,170] DEBUG: MainThread: Refreshing repository session.
[2018-12-15 22:06:29,171] DEBUG: MainThread: Starting new HTTPS connection (1): login.microsoftonline.com
[2018-12-15 22:06:29,520] DEBUG: MainThread: https://login.microsoftonline.com:443 "POST /common/oauth2/v2.0/token HTTP/1.1" 200 3219
[2018-12-15 22:06:29,566] INFO: MainThread: Session for account FOO will expire in 3599 seconds.
[2018-12-15 22:06:29,566] DEBUG: MainThread: Will refresh session in 3479 seconds.
[2018-12-15 22:06:29,574] INFO: MainThread: Sweeping onedrive_client temporary files from local repositories.
[2018-12-15 22:06:29,577] DEBUG: Worker-0: Started.
[2018-12-15 22:06:29,578] DEBUG: Worker-1: Started.
[2018-12-15 22:06:29,579] DEBUG: Worker-2: Started.
[2018-12-15 22:06:29,579] DEBUG: Worker-3: Started.
[2018-12-15 22:06:29,579] DEBUG: Worker-4: Started.
[2018-12-15 22:06:29,579] DEBUG: Worker-5: Started.
[2018-12-15 22:06:29,580] DEBUG: Worker-6: Started.
[2018-12-15 22:06:29,580] DEBUG: Worker-7: Started.
[2018-12-15 22:06:29,580] DEBUG: Worker-8: Started.
[2018-12-15 22:06:29,580] DEBUG: Worker-9: Started.
[2018-12-15 22:06:29,580] DEBUG: Worker-10: Started.
[2018-12-15 22:06:29,581] DEBUG: Worker-11: Started.
[2018-12-15 22:06:29,581] DEBUG: Worker-12: Started.
[2018-12-15 22:06:29,581] DEBUG: Worker-13: Started.
[2018-12-15 22:06:29,581] DEBUG: Worker-14: Started.
[2018-12-15 22:06:29,581] DEBUG: Worker-15: Started.
[2018-12-15 22:06:30,593] INFO: MainThread: Local ngrok API url: http://127.0.0.1:4040/api
[2018-12-15 22:06:30,600] DEBUG: MainThread: Starting new HTTP connection (1): 127.0.0.1
[2018-12-15 22:06:30,602] DEBUG: MainThread: http://127.0.0.1:4040 "GET /api/tunnels HTTP/1.1" 200 389
[2018-12-15 22:06:30,603] DEBUG: WebhookWorker: Started.
[2018-12-15 22:06:30,603] INFO: Webhook: Local webhook server listening on port 42717.
[2018-12-15 22:06:30,604] INFO: Webhook: Webhook server listening on https://foo.ngrok.io/oOSyis.
[2018-12-15 22:06:30,607] DEBUG: MainThread: Adding task StartRepositoryTask(drive=foo)...
[2018-12-15 22:06:30,607] INFO: MainThread: Scheduled sync task for Drive foo of account foo.
[2018-12-15 22:06:30,607] DEBUG: Worker-0: Got task StartRepositoryTask(drive=foo).
[2018-12-15 22:06:30,607] INFO: MainThread: Updating webhook for Drive foo.
[2018-12-15 22:06:30,608] DEBUG: MainThread: Starting new HTTPS connection (1): graph.microsoft.com
[2018-12-15 22:06:30,608] DEBUG: Worker-0: Adding task MergeDirectoryTask(/home/me/OneDriveBusiness, deep=True, remote_unchanged=False, parent_remote_unchanged=False)...
[2018-12-15 22:06:30,608] DEBUG: Worker-0: Got task MergeDirectoryTask(/home/me/OneDriveBusiness, deep=True, remote_unchanged=False, parent_remote_unchanged=False).
[2018-12-15 22:06:30,609] DEBUG: Worker-0: Removing watcher for "/home/me/OneDriveBusiness"
[2018-12-15 22:06:30,610] DEBUG: Worker-0: Starting new HTTPS connection (1): graph.microsoft.com
[2018-12-15 22:06:30,745] DEBUG: Worker-0: https://graph.microsoft.com:443 "GET /v1.0/me/drives/foo/root:/:/children HTTP/1.1" 400 None
[2018-12-15 22:06:30,745] ERROR: Worker-0: Encountered API Error: BadRequest - Resource not found for the segment 'root:'..
[2018-12-15 22:06:30,746] ERROR: Worker-0: Encountered API Error: BadRequest - Resource not found for the segment 'root:'.. Skip directory "".
[2018-12-15 22:06:30,750] DEBUG: MainThread: https://graph.microsoft.com:443 "POST /v1.0/me/drives/foo/root:/:/subscriptions HTTP/1.1" 400 None
[2018-12-15 22:06:30,751] ERROR: MainThread: Error: BadRequest - Resource not found for the segment 'root:'.
[2018-12-15 22:06:30,752] WARNING: MainThread: Failed to create webhook. Will deep sync again in 21600 sec.
[2018-12-15 22:06:30,752] WARNING: MainThread: Executing <Handle gen_start_repo_tasks({'foo': [<onedrive_cli...foo>]}) at /tmp/onedriveClient/onedrive_client/od_main.py:129 created at /tmp/onedriveClient/onedrive_client/od_main.py:207> took 0.145 seconds

@baztian
Copy link

baztian commented Dec 15, 2018

Further more adding my non business account results in

Successfully authorized onedrive_client.
Failed to save account: 'givenName'.

@derrix060
Copy link
Owner

Hello @baztian thanks for the feedback. Can you confirm your python version and the hash for the commits:

$ python --version
$ git rev-parse --verify HEAD
# Output should be 609cd52
$ cd graph-sdk-python
$ git rev-parse --verify HEAD
# Output should be 2d0bf8b

# Also the versions
$ pip freeze | grep onedrive

@derrix060
Copy link
Owner

I've just seen that the commands to install the graph-sdk-python were wrong.

Try this instead:

git clone https://github.com/derrix060/onedriveClient.git
cd onedriveClient
git checkout "#26-use-ms-graph-api"
pip3 install .

# new part
git clone --recurse-submodules -j8 https://github.com/derrix060/graph-sdk-python.git
cd graph-sdk-python
git checkout 2d0bf8b82925e8af2da8b39d5418265b4b42892e
pip3 installl .

@baztian
Copy link

baztian commented Dec 16, 2018

Thanks @derrix060, still same error after following your instructions exactly.

Python 3.5.2
git rev-parse --verify HEAD
609cd52
git rev-parse --verify HEAD
2d0bf8b82925e8af2da8b39d5418265b4b42892e
-e git+https://github.com/derrix060/onedriveClient.git@609cd52394157a5a23ca6aea54b67b091b01bcf0#egg=onedriveClient
onedrivesdk==1.1.8

@ghost
Copy link
Author

ghost commented Dec 20, 2018

@derrix060 I followed your instructions above, and fixed the syntax error in od_auth.py. Various commands then gave the error:

TypeError: __new__() missing 1 required positional argument: 'ignorefile_path'

For example:

rodom@oe2134:~$ onedrive-client start --debug
Starting onedrive-client ... OK
[2018-12-20 11:56:58,552] DEBUG: MainThread: Starting new HTTPS connection (1): login.microsoftonline.com:443
[2018-12-20 11:56:58,806] DEBUG: MainThread: https://login.microsoftonline.com:443 "POST /common/oauth2/v2.0/token HTTP/1.1" 200 3235
[2018-12-20 11:56:58,919] DEBUG: MainThread: Starting new HTTPS connection (1): graph.microsoft.com:443
[2018-12-20 11:56:59,604] DEBUG: MainThread: https://graph.microsoft.com:443 "GET /v1.0/me/drives HTTP/1.1" 200 None
Traceback (most recent call last):
  File "/home/rodom/bin/onedrive-client", line 11, in <module>
    load_entry_point('onedriveClient==2.0.1', 'console_scripts', 'onedrive-client')()
  File "/home/rodom/.local/lib/python3.5/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/rodom/.local/lib/python3.5/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/rodom/.local/lib/python3.5/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/rodom/.local/lib/python3.5/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/rodom/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/rodom/.local/lib/python3.5/site-packages/daemonocle/cli.py", line 57, in subcommand
    daemon.do_action(name)
  File "/home/rodom/.local/lib/python3.5/site-packages/daemonocle/core.py", line 608, in do_action
    func()
  File "/home/rodom/.local/lib/python3.5/site-packages/daemonocle/core.py", line 477, in start
    self._run()
  File "/home/rodom/.local/lib/python3.5/site-packages/daemonocle/core.py", line 399, in _run
    self.worker()
  File "/home/rodom/.local/lib/python3.5/site-packages/onedrive_client/od_main.py", line 195, in main
    all_accounts = get_repo_table(context)
  File "/home/rodom/.local/lib/python3.5/site-packages/onedrive_client/od_main.py", line 103, in get_repo_table
    for d in drives if d.id in ctx.config['drives']]
  File "/home/rodom/.local/lib/python3.5/site-packages/onedrive_client/od_main.py", line 103, in <listcomp>
    for d in drives if d.id in ctx.config['drives']]
  File "/home/rodom/.local/lib/python3.5/site-packages/onedrive_client/od_context.py", line 159, in get_drive
    return _drive_config.LocalDriveConfig(**self.config['drives'][drive_id])
TypeError: __new__() missing 1 required positional argument: 'ignorefile_path'
[2018-12-20 11:56:59,696] DEBUG: Dummy-1: Close <_UnixSelectorEventLoop running=False closed=False debug=True>
All children are gone. Parent is exiting...

This was also seen on onedrive-client-pref drive set. On investigation it was because my existing config file ~/.config/onedrive_client/onedrive_client_config_v2.json was missing the ignorefile_path key under drives - adding it manually to the file allowed onedrive-client to start. However, shouldn't the code be tolerant of this being missing?

@derrix060
Copy link
Owner

Thanks for your feedback @rodom.I think your problem can be in a different issue, since it's affecting not only this branch, as far as I'm aware. BTW, after adding a ignorefile_path key, did you have any problem?

@ghost
Copy link
Author

ghost commented Dec 21, 2018

@derrix060 it seems to be working OK after that!

@tomas-lipensky
Copy link

Is the issue solved? I have connected my business account and I cannot see any disk. From logs:

onedrive-client start --debug
Starting onedrive-client ... OK
[2019-01-08 15:05:53,761] DEBUG: MainThread: Starting new HTTPS connection (1): login.microsoftonline.com
[2019-01-08 15:05:54,199] DEBUG: MainThread: https://login.microsoftonline.com:443 "POST /common/oauth2/token HTTP/1.1" 200 2797
[2019-01-08 15:05:54,265] DEBUG: MainThread: Starting new HTTPS connection (1): oriflamecosmetics-my.sharepoint.com
[2019-01-08 15:05:54,568] DEBUG: MainThread: https://xxxx-my.sharepoint.com:443 "GET /_api/v2.0/drives HTTP/1.1" 200 None
[2019-01-08 15:05:54,575] INFO: MainThread: No Drive associated with account "[email protected]" (XXXX).
[2019-01-08 15:05:54,576] INFO: MainThread: Sweeping onedrive_client temporary files from local repositories.

If I run GET request https://xxxxx-my.sharepoint.com/_api/v2.0/drives in my browser, I get 3 drives. Maybe the output of the API request has changed?

@derrix060
Copy link
Owner

@tomas-lipensky As I said before, there is an error with the microsoft API. Please test the instructions from here and if it fixes, I can make the changes repo-wide.

@Rasori
Copy link

Rasori commented Jan 10, 2019

I am not 100% sure that I got it right (newbie here), but following pointed instruction I ended in situation where I get following message :

Error initializing plugin EntryPoint('Windows (alt)', 'keyrings.alt.Windows', None, Distribution('keyrings.alt', '3.0')).
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/keyring/backend.py", line 163, in _load_plugins
    init_func = ep.load()
  File "/usr/lib/python3/dist-packages/entrypoints.py", line 74, in load
    mod = import_module(self.module_name)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/lib/python3.6/dist-packages/keyrings.alt-3.0-py3.6.egg/keyrings/alt/Windows.py", line 9, in <module>
    from . import file_base
  File "/usr/local/lib/python3.6/dist-packages/keyrings.alt-3.0-py3.6.egg/keyrings/alt/file_base.py", line 13, in <module>
    from keyring.util.escape import escape as escape_for_ini
ModuleNotFoundError: No module named 'keyring.util.escape'
Error initializing plugin EntryPoint('file', 'keyrings.alt.file', None, Distribution('keyrings.alt', '3.0')).
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/keyring/backend.py", line 163, in _load_plugins
    init_func = ep.load()
  File "/usr/lib/python3/dist-packages/entrypoints.py", line 74, in load
    mod = import_module(self.module_name)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/lib/python3.6/dist-packages/keyrings.alt-3.0-py3.6.egg/keyrings/alt/file.py", line 11, in <module>
    from keyring.util.escape import escape as escape_for_ini
ModuleNotFoundError: No module named 'keyring.util.escape'
Error initializing plugin EntryPoint('pyfs', 'keyrings.alt.pyfs', None, Distribution('keyrings.alt', '3.0')).
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/keyring/backend.py", line 163, in _load_plugins
    init_func = ep.load()
  File "/usr/lib/python3/dist-packages/entrypoints.py", line 74, in load
    mod = import_module(self.module_name)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/lib/python3.6/dist-packages/keyrings.alt-3.0-py3.6.egg/keyrings/alt/pyfs.py", line 8, in <module>
    from keyring.util.escape import escape as escape_for_ini
ModuleNotFoundError: No module named 'keyring.util.escape'
Reading drives information from OneDrive server...

Error: invalid_grant.

@derrix060
Copy link
Owner

Hello @Rasori, welcome.

The error that you sent is not related with this issue. There is a problem with your keyring. Please make sure you have configured correctly your environment, following these instructions.

I can see that you have keyring.alt version 3.0, and the latest version is 3.1.1.

@asppsa
Copy link

asppsa commented Mar 25, 2019

@derrix060, I just tried out your #26 branch, using the patched SDK as per your instructions, and it's working for me thus far. This is the first time I have ever been able to sync w my organisation's OneDrive on Linux - thank you so much for this!

@derrix060
Copy link
Owner

Thanks for the feedback @asppsa I'm planning to merge the #26 into the master and let this be the default. I just need some time to figure out how to do this and support as many user that before without major issues.

I'm also applying for a new job where I'm leaving, so it might take some weeks ;)

@mrIom
Copy link

mrIom commented Sep 19, 2019

For me didn't work the #26, not showing any drives for onedrive business...
Are you looking into https://[domain]-my.sharepoint.com/personal/[business-email]/_api/v2.0/drives?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants