Skip to content

Add a OneDrive account

Every document CtrlShare checks out goes into one OneDrive account, and stays there until it is checked back in. This connects that account.

The same steps re-authorise an account whose consent has expired, which is the more common reason to be on this page. Nothing else in the configuration changes.

  • The Application (client) ID and client secret from the Entra ID registration, with http://localhost/ctrlshare registered as a Web redirect URI.
  • The credentials of the service account whose OneDrive will hold the files.
  • A browser you can sign in to that account with. Sign out of any other Microsoft account first — the consent is granted as whoever is signed in, and there is no confirmation afterwards saying which account that was.
  1. Open the CtrlShare configuration.

    In M-Files Admin, connect to the server, open the vault, and select Configurations → Other Applications → CtrlShare → Configuration.

  2. Fill in the OneDrive for Business section.

    Setting Value
    Client ID The Application (client) ID from the Entra registration
    Client Secret The client secret from the Entra registration
    Redirect URI Leave the default, http://localhost/ctrlshare

    The redirect URI has to match one registered on the Entra application exactly, trailing slash included.

  3. Sign in to the service account.

    Open office.com in a browser and sign in as the service account. This is the account the consent in the next step is granted for.

  4. Open the authorisation URL.

    Put the Application (client) ID in place of APPLICATIONID and open the result in the same browser:

    https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize?client_id=APPLICATIONID&response_type=code&scope=Files.ReadWrite.All%20offline_access&redirect_uri=http://localhost/ctrlshare

    A consent page appears listing the permissions. Select Accept.

    The Microsoft Permissions requested page for CtrlShare, with Accept highlighted.

    The consent page. It lists the permissions named in the authorisation URL; this one comes from an older URL, which also asked to read users' basic profiles.
  5. Copy the address from the address bar.

    The browser then reports that it cannot connect to localhost. That is expected: nothing runs at that address, and the page exists only to hold the result. The address bar keeps it:

    http://localhost/ctrlshare?code=0.AUgAvawd…deu&session_state=xxxxxxxx

    Copy the whole address.

  6. Paste it into the configuration and save.

    Paste the address into Authorization Code and save. CtrlShare takes the code out of it, so the code alone works as well. Saving exchanges the code for a token CtrlShare can refresh, and a code can only be exchanged once.

M-Files Admin does not show whether the exchange worked. A failed exchange is written to the vault application log, so look there first.

Then check a document out to OneDrive and back in. The connection can look right and still fail on first use, and a real check-out is the only thing that proves it.