OneDrive / onedrive-api-docs

Official documentation for the OneDrive API
MIT License
447 stars 228 forks source link

"Tenant does not have a SPO license" though the authenticated user does #1773

Open oliviercailloux opened 6 months ago

oliviercailloux commented 6 months ago

Category

Expected or Desired Behavior

Access the user’s drives

Observed Behavior

Obtain “Tenant does not have a SPO license.”

Steps to Reproduce

client_id = my-app-client-id
tenant_id = my-tenant-id
user = some-user-that-has-access-to-share-point-online

import msal, requests

msal_app = msal.PublicClientApplication(client_id, authority=f"https://login.microsoftonline.com/{tenant_id}")
scopes = ("Files.Read", )

acquired_token = msal_app.acquire_token_interactive(scopes, login_hint=user)

drive = requests.get(
    "https://graph.microsoft.com/v1.0/me/drive", headers={"Authorization": f"Bearer {acquired_token['access_token']}"}
).json()
assert drive["error"]["message"] == "Tenant does not have a SPO license."

I could not find out how to determine which license is required in which case, if at all. I find it odd that I (as an app developer) would need a license when my app acts on behalf of a user who does have the license. Moreover, it seems that some persons are able to work around the need for a license, which suggests that the error message is incorrect.