Authenticating to Microsoft 365 Business services (SharePoint and OneDrive for Business) has some specific complexities.
The default "common" tenant for business_onedrive
and sharepoint_site
attempts to detect your actual tenant from your saved credentials in your browser. This may not always succeed, for example if you have a personal account that is also a guest account in a tenant. In this case, supply the actual tenant name, either in the tenant
argument or in the CLIMICROSOFT365_TENANT
environment variable. The latter allows sharing authentication details with the CLI for Microsoft 365.
The default when authenticating to these services is for Microsoft365R to use its own internal app ID. Depending on your organisation's security policy, you may have to get an admin to grant it access to your tenant. As an alternative to the default app ID, you (or your admin) can create your own app registration: it should have a native redirect URI of http://localhost:1410
, and the "public client" option should be enabled if you want to use the device code authentication flow. You can supply your app ID either via the app
argument, or in the environment variable CLIMICROSOFT365_AADAPPID
.
If creating your own app registration is impractical, it's possible to work around access issues by piggybacking on the CLI for Microsoft365. By setting the R option microsoft365r_use_cli_app_id
to a non-NULL value, authentication will be done using the CLI's app ID. Technically this app still requires admin approval, but it is in widespread use and so may already be allowed in your organisation. Be warned that this solution may draw the attention of your admin!