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

OneDrive won't login with OAuth2 #56

Closed
Venthe opened this issue Sep 1, 2022 · 8 comments
Closed

OneDrive won't login with OAuth2 #56

Venthe opened this issue Sep 1, 2022 · 8 comments

Comments

@Venthe
Copy link

Venthe commented Sep 1, 2022

Hello,
I cannot run the GUI. It asks for Oauth, saves it - but when I click to start the sync it asks for oauth again.

Sync via onedrive cli/systemd works

Operating System: Debian GNU/Linux 11 (MX 21.2)
KDE Plasma Version: 5.20.5
KDE Frameworks Version: 5.78.0
Qt Version: 5.15.2
Kernel Version: 5.18.0-4mx-amd64
OS Type: 64-bit
Processors: 8 × Intel® Core™ i5-8250U CPU @ 1.60GHz
Memory: 15,5 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 620
2022-09-01 07:29:45,992 [OneDriveGUI.py:2824][fn=save_global_config][INFO] - <my_profile_name> config saved
2022-09-01 07:29:45,992 [OneDriveGUI.py:2826][fn=save_global_config][INFO] - All configs saved
2022-09-01 07:29:46,650 [OneDriveGUI.py:2845][fn=main_window_start_state][INFO] - [GUI] Starting OneDriveGUI maximized
2022-09-01 07:29:46,653 [OneDriveGUI.py:1054][fn=__init__][INFO] - <my_profile_name>
2022-09-01 07:29:50,521 [OneDriveGUI.py:1940][fn=__init__][INFO] - [GUI] Starting worker for profile <my_profile_name>
2022-09-01 07:29:50,522 [OneDriveGUI.py:2467][fn=start_onedrive_monitor][INFO] - [GUI] Opening external login window
2022-09-01 07:29:50,559 [OneDriveGUI.py:2013][fn=read_stdout][INFO] - [<my_profile_name>] Using 'user' Config Dir: /home/venthe/.config/onedrive/accounts/<my_profile_name>
2022-09-01 07:29:50,561 [OneDriveGUI.py:2013][fn=read_stdout][INFO] - [<my_profile_name>] Using config option for Global Azure AD Endpoints
2022-09-01 07:29:50,561 [OneDriveGUI.py:2013][fn=read_stdout][INFO] - [<my_profile_name>] Configuration file successfully loaded
2022-09-01 07:29:51,335 [OneDriveGUI.py:2013][fn=read_stdout][INFO] - [<my_profile_name>] Checking Application Version ...
2022-09-01 07:29:51,980 [OneDriveGUI.py:2013][fn=read_stdout][INFO] - [<my_profile_name>] Initializing the OneDrive API ...
2022-09-01 07:29:51,981 [OneDriveGUI.py:2013][fn=read_stdout][INFO] - [<my_profile_name>] Configuring Global Azure AD Endpoints
2022-09-01 07:29:51,982 [OneDriveGUI.py:2013][fn=read_stdout][INFO] - [<my_profile_name>] Using Curl defaults for all HTTP operations
2022-09-01 07:29:51,982 [OneDriveGUI.py:2013][fn=read_stdout][INFO] - [<my_profile_name>] User Configured Rate Limit: 125000000
2022-09-01 07:29:51,983 [OneDriveGUI.py:2013][fn=read_stdout][INFO] - [<my_profile_name>] Authorize this app visiting:
2022-09-01 07:29:51,984 [OneDriveGUI.py:2013][fn=read_stdout][INFO] - [<my_profile_name>] https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=<client_id>scope=Files.ReadWrite%20Files.ReadWrite.all%20Sites.Read.All%20Sites.ReadWrite.All%20offline_access&response_type=code&prompt=login&redirect_uri=https://login.microsoftonline.com/common/oauth2/nativeclient
2022-09-01 07:29:52,003 [OneDriveGUI.py:2013][fn=read_stdout][INFO] - [<my_profile_name>] Enter the response uri:
2022-09-01 07:29:53,006 [OneDriveGUI.py:2478][fn=<lambda>][INFO] - finished worker <my_profile_name>
2022-09-01 07:29:53,006 [OneDriveGUI.py:1951][fn=stop_worker][INFO] - [<my_profile_name>] Waiting for worker to finish...
2022-09-01 07:29:53,006 [OneDriveGUI.py:1955][fn=stop_worker][INFO] - [<my_profile_name>] Quitting thread
2022-09-01 07:29:53,006 [OneDriveGUI.py:1958][fn=stop_worker][INFO] - [<my_profile_name>] Removing thread info
2022-09-01 07:29:53,006 [OneDriveGUI.py:1961][fn=stop_worker][INFO] - [GUI] Remaining running workers: {}
2022-09-01 07:29:59,453 [OneDriveGUI.py:2643][fn=get_response_url][INFO] - exec onedrive --confdir="/home/venthe/.config/onedrive/accounts/<my_profile_name>" --auth-response "https://login.microsoftonline.com/common/oauth2/nativeclient?code=<client_id>"
2022-09-01 07:29:59,467 [OneDriveGUI.py:2645][fn=get_response_url][INFO] - Login performed
Traceback (most recent call last):
  File "/tmp/.mount_OneDriVgJRVf//usr/src/OneDriveGUI.py", line 2629, in <lambda>
    self.lw2.pushButton_save.clicked.connect(lambda: self.get_response_url(self.lw2.lineEdit_response_url.text(), self.config_dir, profile))
  File "/tmp/.mount_OneDriVgJRVf//usr/src/OneDriveGUI.py", line 2650, in get_response_url
    main_window.workers[profile].stop_worker()
KeyError: '<my_profile_name>'

@bpozdena
Copy link
Owner

bpozdena commented Sep 1, 2022

Hi @Venthe ,

By just looking at the error, it looks like the login was successful and the error is caused by an unneeded/legacy code that does not do anything in the AppImage version. I will try to look into this in the next couple of days.

Technically, you should be able to start the sync manually by clicking the 'Play' button. If not, please share the entire event log with two consecutive failed sync attempts.

@Venthe
Copy link
Author

Venthe commented Sep 1, 2022

Play button results in another OAuth request without any interesting logs

@bpozdena
Copy link
Owner

bpozdena commented Sep 3, 2022

@Venthe , please try this updated OneDriveGUI-1.0.0_issue56-x86_64.AppImage

I don't think it will resolve your login issue, but it should at least allow you to see why the login fails.

If sync fails again, please provide the console output from the updated AppImage.

Also provide output of the bellow commands:

onedrive --version
onedrive --confdir="/home/venthe/.config/onedrive/accounts/venthe" --logout -v
onedrive --confdir="/home/venthe/.config/onedrive/accounts/venthe" -v 
<<< Enter OAuth2 response URL
onedrive --confdir="/home/venthe/.config/onedrive/accounts/venthe" --monitor -v
ls -la /home/venthe/.config/onedrive/accounts/venthe/
cat /home/venthe/.config/onedrive/accounts/venthe/config

@Venthe
Copy link
Author

Venthe commented Sep 3, 2022

2022-09-04 01:46:01,170 [OneDriveGUI.py:2038][fn=read_stdout][INFO] - [venthe] https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=CLIENT_ID&scope=Files.ReadWrite%20Files.ReadWrite.all%20Sites.Read.All%20Sites.ReadWrite.All%20offline_access&response_type=code&prompt=login&redirect_uri=https://login.microsoftonline.com/common/oauth2/nativeclient
2022-09-04 01:46:01,191 [OneDriveGUI.py:2038][fn=read_stdout][INFO] - [venthe] Enter the response uri:
2022-09-04 01:46:02,193 [OneDriveGUI.py:2503][fn=<lambda>][INFO] - finished worker venthe
2022-09-04 01:46:02,193 [OneDriveGUI.py:1972][fn=stop_worker][INFO] - [venthe] Waiting for worker to finish...
2022-09-04 01:46:02,193 [OneDriveGUI.py:1976][fn=stop_worker][INFO] - [venthe] Quitting thread
2022-09-04 01:46:02,193 [OneDriveGUI.py:1979][fn=stop_worker][INFO] - [venthe] Removing thread info
2022-09-04 01:46:02,193 [OneDriveGUI.py:1982][fn=stop_worker][INFO] - [GUI] Remaining running workers: {}
2022-09-04 01:46:51,140 [OneDriveGUI.py:2668][fn=get_response_url][INFO] - exec onedrive --confdir="/home/venthe/.config/onedrive/accounts/venthe" --auth-response "https://login.microsoftonline.com/common/oauth2/nativeclient?code=<CODE>"
2022-09-04 01:46:51,160 [OneDriveGUI.py:2670][fn=get_response_url][INFO] - Login performed
2022-09-04 01:47:01,906 [OneDriveGUI.py:1961][fn=__init__][INFO] - [GUI] Starting worker for profile venthe
2022-09-04 01:47:01,907 [OneDriveGUI.py:2492][fn=start_onedrive_monitor][INFO] - [GUI] Opening external login window
2022-09-04 01:47:01,944 [OneDriveGUI.py:2038][fn=read_stdout][INFO] - [venthe] Using 'user' Config Dir: /home/venthe/.config/onedrive/accounts/venthe
2022-09-04 01:47:01,945 [OneDriveGUI.py:2038][fn=read_stdout][INFO] - [venthe] Using config option for Global Azure AD Endpoints
2022-09-04 01:47:01,945 [OneDriveGUI.py:2038][fn=read_stdout][INFO] - [venthe] Configuration file successfully loaded
2022-09-04 01:47:02,228 [OneDriveGUI.py:2038][fn=read_stdout][INFO] - [venthe] Checking Application Version ...
2022-09-04 01:47:02,369 [OneDriveGUI.py:2038][fn=read_stdout][INFO] - [venthe] Initializing the OneDrive API ...
2022-09-04 01:47:02,370 [OneDriveGUI.py:2038][fn=read_stdout][INFO] - [venthe] Configuring Global Azure AD Endpoints
2022-09-04 01:47:02,370 [OneDriveGUI.py:2038][fn=read_stdout][INFO] - [venthe] Using Curl defaults for all HTTP operations
2022-09-04 01:47:02,371 [OneDriveGUI.py:2038][fn=read_stdout][INFO] - [venthe] User Configured Rate Limit: 125000000
2022-09-04 01:47:02,371 [OneDriveGUI.py:2038][fn=read_stdout][INFO] - [venthe] Authorize this app visiting:
2022-09-04 01:47:02,372 [OneDriveGUI.py:2038][fn=read_stdout][INFO] - [venthe] https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=CLIENT_ID&scope=Files.ReadWrite%20Files.ReadWrite.all%20Sites.Read.All%20Sites.ReadWrite.All%20offline_access&response_type=code&prompt=login&redirect_uri=https://login.microsoftonline.com/common/oauth2/nativeclient
2022-09-04 01:47:02,378 [OneDriveGUI.py:2038][fn=read_stdout][INFO] - [venthe] Enter the response uri:
2022-09-04 01:47:03,396 [OneDriveGUI.py:2503][fn=<lambda>][INFO] - finished worker venthe
2022-09-04 01:47:03,396 [OneDriveGUI.py:1972][fn=stop_worker][INFO] - [venthe] Waiting for worker to finish...
2022-09-04 01:47:03,396 [OneDriveGUI.py:1976][fn=stop_worker][INFO] - [venthe] Quitting thread
2022-09-04 01:47:03,396 [OneDriveGUI.py:1979][fn=stop_worker][INFO] - [venthe] Removing thread info
2022-09-04 01:47:03,396 [OneDriveGUI.py:1982][fn=stop_worker][INFO] - [GUI] Remaining running workers: {}

I've executed the same command as in 2022-09-04 01:46:51,140, namely onedrive --confdir="/home/venthe/.config/onedrive/accounts/venthe" --auth-response "https://login.microsoftonline.com/common/oauth2/nativeclient?code=CODE" with --synchronize switch and it worked (manually)

@Venthe
Copy link
Author

Venthe commented Sep 3, 2022

It has worked by removing the authorization (--logout) then re-authorizing. Thanks a bunch!

@Venthe Venthe closed this as completed Sep 3, 2022
@Ghostbird
Copy link

I've still got this issue with the latest OneDriveGui. log
Authentication works fine when using the onedrive command line interface. I've tried the --logout option as mentioned by @Venthe, but it didn't solve the issue for me. Log is from after I just did the --logout.

@bpozdena
Copy link
Owner

There is definitely room for improvement in the GUI as it currently does not really verify the response from Office365.

This behavior most likely means that the client did not authenticate correctly.

For now, you can just login manually in console by running the bellow commands. The first one will remove any pre-existing logon details, the 2nd command will prompt you to enter new response URL and the 3rd one should just verify if you are logged on correctly.

If you are not prompted to enter new logon URL on the 3rd command, then the sync in GUI should work fine.

onedrive --confdir='/home/gijsbert/.config/onedrive/accounts/conneqt' --logout -v
onedrive --confdir='/home/gijsbert/.config/onedrive/accounts/conneqt' -v
onedrive --confdir='/home/gijsbert/.config/onedrive/accounts/conneqt' -v

Please share the outputs if something fails.

@bpozdena
Copy link
Owner

The next release will have better logon attempt validation for AppImage users.

Example when expired response URL is provided:
image

Example of invalid response code:
image

Example of successful login:
image

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

No branches or pull requests

3 participants