Your hypothesis is right. Workspace SCIM (including /Me) only returns groups that are assigned to the workspace. Your account SCIM calls failed because both tokens you tried are workspace-scoped. The user's OBO token and the app service principal's token are issued by the workspace, and the accounts host rejects them no matter what workspace admin or group permissions the identity has. To read account-level membership without assigning the groups to the workspace, call the account SCIM API with an account-level OAuth token. That token comes from a dedicated service principal with the account admin role.
Setup
1. In the account console, create a service principal (e.g. app-group-reader), give it the Account admin role, and generate an OAuth secret for it at the account level.
2. Store the client ID and secret in a secret scope and add them as secret resources on the app, so they reach the app as env vars.
3. In the app, get the user's email from the X-Forwarded-Email header. Resolve the user's account ID, then check it against the members of your role groups:
import os, time
from databricks.sdk import AccountClient
acct = AccountClient(
host="https://accounts.azuredatabricks.net",
account_id=os.environ["DATABRICKS_ACCOUNT_ID"],
client_id=os.environ["GROUP_READER_CLIENT_ID"],
client_secret=os.environ["GROUP_READER_SECRET"],
)
ROLE_GROUPS = {"app-admins": "<group-id>", "app-analysts": "<group-id>"} # account group IDs
_cache = {"ts": 0, "members": {}}
def _members():
if time.time() - _cache["ts"] > 600: # refresh every 10 min
_cache["members"] = {
role: {m.value for m in (acct.groups.get(id=gid).members or [])}
for role, gid in ROLE_GROUPS.items()
}
_cache["ts"] = time.time()
return _cache["members"]
def roles_for(email: str) -> set[str]:
users = list(acct.users.list(filter=f'userName eq "{email}"', attributes="id"))
if not users:
return set()
uid = users[0].id
return {role for role, ids in _members().items() if uid in ids}
Cache the user ID per session as well, so a page load doesn't make an account API call.
Notes
- Only check the handful of groups that drive features in your app. Don't enumerate everything a user belongs to.
- If your Entra groups are nested, members can contain groups. Flatten them, or use flat groups for app roles.
- Keep the secret out of the app code and the bundle. The secret resource is the right place for it.
- If an account admin SP is too much privilege for your security team, the alternative is to skip Databricks and ask Entra directly. Use Microsoft Graph checkMemberGroups for the user's email, with an app registration that has GroupMember.Read.All. Since the groups come from Entra anyway, that's equally valid.
Docs: https://learn.microsoft.com/en-us/azure/databricks/dev-tools/auth/oauth-m2m (account-level token section) and https://learn.microsoft.com/en-us/azure/databricks/dev-tools/databricks-apps/auth