Closed etikatech closed 4 years ago
@etikatech The issue here is 100% likely to do with how you are starting the service & what service file you are using under CentOS. I suspect what you have done is 'authorised' the client using a non-root user (normal user account), but then configured the systemd services to utilise the 'root' service account, which, is not authorised, hence the type of error you are seeing.
What you need to do is remove & disable that service configuration, and set it up to run as your normal user.
For further details, refer to:
Example:
[alex@centos7full ~]$ systemctl enable onedrive@alex.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-unit-files ===
Authentication is required to manage system service or unit files.
Authenticating as: alex
Password:
==== AUTHENTICATION COMPLETE ===
Created symlink from /etc/systemd/system/multi-user.target.wants/onedrive@alex.service to /usr/lib/systemd/system/onedrive@.service.
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentication is required to reload the systemd state.
Authenticating as: alex
Password:
==== AUTHENTICATION COMPLETE ===
[alex@centos7full ~]$ systemctl start onedrive@alex.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: alex
Password:
==== AUTHENTICATION COMPLETE ===
[alex@centos7full ~]$ journalctl --unit=onedrive@alex -f
...
Sep 18 06:09:47 centos7full systemd[1]: Started OneDrive Free Client for alex.
Sep 18 06:09:47 centos7full onedrive[12862]: Configuration file successfully loaded
Sep 18 06:09:47 centos7full onedrive[12862]: Notification (dbus) server not available, disabling
Sep 18 06:09:48 centos7full onedrive[12862]: Configuring Global Azure AD Endpoints
Sep 18 06:09:51 centos7full onedrive[12862]: Initializing the Synchronization Engine ...
Sep 18 06:09:51 centos7full onedrive[12862]: Initializing monitor ...
Sep 18 06:09:51 centos7full onedrive[12862]: OneDrive monitor interval (seconds): 30
...
Closing issue as question answered
@abraunegg thanks for the response!
I had actually authorised the client using the root user, and was also using root for systemd. So, there may still be a problem here..
I know that it is better practice to use a non-root user, so I'll try that and let you know how I go.
Thanks again.
@etikatech
I just tested again via using 'root' to configure the application & systemd service - again, no issue identified as per below:
[root@centos7full ~]# cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
[root@centos7full ~]# which onedrive
/usr/local/bin/onedrive
[root@centos7full ~]# onedrive --version
onedrive v2.4.5-13-g1364f36
[root@centos7full ~]# whoami
root
[root@centos7full ~]# ls -la ~/.config/onedrive/
total 0
drwxr-xr-x. 2 root root 6 Nov 19 2019 .
drwx------. 15 root root 277 Nov 19 2019 ..
[root@centos7full ~]# onedrive
Configuring Global Azure AD Endpoints
Authorize this app visiting:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=d50ca740-c83f-4d1b-b616-12c519384f0c&scope=Files.ReadWrite%20Files.ReadWrite.all%20Sites.Read.All%20Sites.ReadWrite.All%20offline_access&response_type=code&redirect_uri=https://login.microsoftonline.com/common/oauth2/nativeclient
Enter the response uri: https://login.microsoftonline.com/common/oauth2/nativeclient?code=<redacted>
Application has been successfully authorised, however no additional command switches were provided.
Please use --help for further assistance in regards to running this application.
[root@centos7full ~]# onedrive --synchronize --verbose --dry-run
Using 'user' Config Dir: /root/.config/onedrive
Using 'system' Config Dir: /etc/onedrive
No user or system config file found, using application defaults
DRY-RUN Configured. Output below shows what 'would' have occurred.
Initializing the OneDrive API ...
Configuring Global Azure AD Endpoints
Opening the item database ...
All operations will be performed in: /root/OneDrive
Application version: v2.4.5-13-g1364f36
Account Type: business
Default Drive ID: b!bO8V7s9SSk6r7mWHpIjURotN33W1W2tEv3OXV_oFIdQimEdOHR-1So7CqeT1MfHA
Default Root ID: 01WIXGO5V6Y2GOVW7725BZO354PWSELRRZ
Remaining Free Space: 1088262641423
Fetching details for OneDrive Root
OneDrive Root does not exist in the database. We need to add it.
Added OneDrive Root to the local database
Initializing the Synchronization Engine ...
Syncing changes from OneDrive ...
Applying changes of Path ID: 01WIXGO5V6Y2GOVW7725BZO354PWSELRRZ
Updated Remaining Free Space: 1088262641423
Number of items from OneDrive to process: 2
Downloading file test.txt ... done.
Uploading differences of ~/OneDrive
Processing .
The directory has not changed
Processing test.txt
The file has not changed
Uploading new items of ~/OneDrive
Applying changes of Path ID: 01WIXGO5V6Y2GOVW7725BZO354PWSELRRZ
Updated Remaining Free Space: 1088262641423
[root@centos7full ~]# onedrive --synchronize --verbose
Using 'user' Config Dir: /root/.config/onedrive
Using 'system' Config Dir: /etc/onedrive
No user or system config file found, using application defaults
Initializing the OneDrive API ...
Configuring Global Azure AD Endpoints
Opening the item database ...
All operations will be performed in: /root/OneDrive
Application version: v2.4.5-13-g1364f36
Account Type: business
Default Drive ID: b!bO8V7s9SSk6r7mWHpIjURotN33W1W2tEv3OXV_oFIdQimEdOHR-1So7CqeT1MfHA
Default Root ID: 01WIXGO5V6Y2GOVW7725BZO354PWSELRRZ
Remaining Free Space: 1088262641423
Fetching details for OneDrive Root
OneDrive Root does not exist in the database. We need to add it.
Added OneDrive Root to the local database
Initializing the Synchronization Engine ...
Syncing changes from OneDrive ...
Applying changes of Path ID: 01WIXGO5V6Y2GOVW7725BZO354PWSELRRZ
Updated Remaining Free Space: 1088262641423
Number of items from OneDrive to process: 2
Downloading file test.txt ... done.
Uploading differences of ~/OneDrive
Processing .
The directory has not changed
Processing test.txt
The file has not changed
Uploading new items of ~/OneDrive
Applying changes of Path ID: 01WIXGO5V6Y2GOVW7725BZO354PWSELRRZ
Updated Remaining Free Space: 1088262641423
[root@centos7full ~]#
[root@centos7full ~]#
[root@centos7full ~]# systemctl enable onedrive
Created symlink from /etc/systemd/system/default.target.wants/onedrive.service to /usr/lib/systemd/system/onedrive.service.
[root@centos7full ~]# systemctl start onedrive
[root@centos7full ~]# journalctl --unit=onedrive -f
-- Logs begin at Wed 2020-09-02 08:35:36 AEST. --
Sep 18 08:49:50 centos7full systemd[1]: Started OneDrive Free Client.
Sep 18 08:49:50 centos7full onedrive[16677]: Notification (dbus) server not available, disabling
Sep 18 08:49:51 centos7full onedrive[16677]: Configuring Global Azure AD Endpoints
Sep 18 08:49:52 centos7full onedrive[16677]: Initializing the Synchronization Engine ...
Sep 18 08:49:52 centos7full onedrive[16677]: Initializing monitor ...
Sep 18 08:49:52 centos7full onedrive[16677]: OneDrive monitor interval (seconds): 300
@abraunegg
Thanks for reply. Issue has been resolved.
I was trying to sync multiple Sharepoint Document Libraries using different config files in separate directories.
I deleted all the files in my config directories and started from scratch again, configuring, synching and enabling one service for each Document Library at a time.
(By the way, I also remove the quotation marks for the conf-dir option in my service file. Not sure if this made a difference.)
It's now all good. 👍
Thanks again for your assistance.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
I have been able to run onedrive manually and it operates as expected, without any problems.
However, when I try to run it as a service using systemd on CentOS 7.8, the logs indicate that onedrive is trying to reauthenticate with Microsoft again:
It appears that when running under systemd, onedrive is not seeing the 'refresh_token' file in the config directory.
My service file is as follows:
Any ideas? Is this a misconfiguration or a possible bug?