grafana/grafana

Allow configurable timeout for Microsoft Entra ID OAuth token exchange to prevent intermittent login failures

Closed

#120.907 aberto em 23 de mar. de 2026

Ver no GitHub
 (19 comments) (0 reactions) (0 assignees)TypeScript (13.868 forks)batch import
area/autharea/auth/oautharea/configurationautomated-triagegood first issuetype/feature-request

Métricas do repositório

Stars
 (73.744 stars)
Métricas de merge de PR
 (Mesclagem média 2d 9h) (1.000 fundiu PRs em 30d)

Description

Why is this needed:

When using Microsoft Entra ID (Azure AD) as an OAuth provider, authentication intermittently fails due to timeouts during the token exchange step.

In our environment, network latency can occasionally be higher than usual. While the Entra ID endpoint is reachable and authentication often succeeds, some requests fail with an i/o timeout before the token is returned.

This results in user-facing login errors such as:

Login failed. Failed to get token from provider

And corresponding Grafana logs:

[auth.oauth.token.exchange] failed to exchange code to token: 
Post "https://login.microsoftonline.com/.../oauth2/v2.0/token": 
dial tcp ...:443: i/o timeout

Currently, there does not appear to be a way to adjust the timeout or retry behavior, which makes authentication unreliable in environments with variable network performance.

What would you like to be added:

The ability to configure the timeout (and optionally retry behavior) for OAuth token exchange requests.

For example, adding configuration options such as:

[auth.azuread]
token_exchange_timeout = 30s
token_exchange_retries = 2

This would allow deployments in higher-latency environments to avoid intermittent authentication failures without impacting default behavior.

Who is this feature for?

  • Users running Grafana in environments with non-ideal or variable network latency (e.g. private cloud networks, VPNs, restricted enterprise environments)
  • Teams integrating Grafana with external identity providers such as Microsoft Entra ID
  • Operators who need more control over authentication reliability and timeout behavior

Guia do colaborador