-
What Grafana version and what operating system are you using?
Grafanamainbranch (also affects current releases). Running on Azure App Service (Linux, Docker). -
What are you trying to achieve?
Using Azure AD OAuth withclient_authentication = managed_identity(User-Assigned Managed Identity) and refresh tokens enabled (use_refresh_token = true) for seamless session continuity. -
How are you trying to achieve it?
Configuration:
[auth.azuread]
enabled = true
client_authentication = managed_identity
managed_identity_client_id =
federated_credential_audience = api://AzureADTokenExchange
use_refresh_token = true
use_pkce = true
scopes = openid profile email offline_access -
What happened?
The initial login works perfectly. However, when the access token expires (~60 minutes), the token refresh fails silently and all users get logged out. This is becauseTokenSource()inazuread_oauth.gofalls through to the defaultoauth2.Config.TokenSource(), which doesnât include aclient_assertionâ unlike workload identity, which already has a dedicatedazureADTokenSourcehandling this correctly. -
What did you expect to happen?
Token refresh should work transparently, just like it does forclient_authentication = workload_identity. The session should continue without interruption. -
Can you copy/paste the configuration(s) that you are having problems with?
-
Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
Yes, on every token refresh attempt:
logger=oauthtoken level=error msg=âFailed to retrieve oauth access tokenâ
provider=oauth_azuread
error=âoauth2: âinvalid_clientâ âAADSTS7000218: The request body must contain the following parameter:
âclient_assertionâ or âclient_secretâ.ââ -
Did you follow any online instructions? If so, what is the URL?
* Grafana docs for Azure AD OAuth configuration with managed identity.Additional context
Iâve filed an issue and submitted a fix with production-verified before/after results:
The fix adds a dedicated
azureADManagedIdentityTokenSourcefollowing the same pattern as the existing workload identity token source. After deploying the fix: zero AADSTS7000218 errors, sessions refresh without interruption.Looking for maintainer review on the PR â itâs been open since Feb 26 with no reviews yet. Thanks!
2 Likes