What Grafana version and what operating system are you using?
Grafana 13.2.3 (grafana/grafana focker image)
What are you trying to achieve?
Forwarding scopes provided by Generic OAuth authentication via a JWT access token to the proxy sitting in front of my Loki backend so it can accept or deny requests based on those scopes.
How are you trying to achieve it?
I configured a Loki datasource with the URL of the proxy sitting in front of my Loki backend, and selected “Authentication method: Forward OAuth Identity”
I configured the Generic OAuth authentication plugin
What happened?
Loky proxy only received following headers:
accept
accept-encoding
accept-language
host
sec-ch-ua
sec-ch-ua-mobile
sec-ch-ua-platform
sec-fetch-dest
sec-fetch-mode
sec-fetch-site
user-agent
x-datasource-uid
x-forwarded-for
x-grafana-id
x-grafana-org-id
x-grafana-referer
x-grafana-user
x-plugin-id
What did you expect to happen?
I expected access token and ID Token obtained from Generic OAuth provider to be forwarded to the proxy sitting in front of Loki via those headers:
Authorization
X-ID-Token
Having information from original Generic OAuth access token (eg: scopes) in x-grafana-id JWT token would also work for me.
Hi @troglogeek, your datasource setup looks right. Since the x-grafana-* headers reach your proxy, the Loki plugin is forwarding headers fine, and the problem is that Grafana isn’t attaching the OAuth token. In 13.2.3 it skips the token when →
The user didn’t log in via Generic OAuth (for example a local admin or a service account), or Grafana has no stored OAuth session for them. Log out, sign in with the OAuth button, and run the query from Explore.
The token refresh failed. Log in again to get a fresh token, and check the log error to see why your provider rejected the refresh.
The query isn’t from a user session (alert rules, background jobs).
To see which one it is, check the Grafana server logs while you run the query. Look for →
The specified user's auth provider is not oauth No external session found for user Failed to refresh OAuth token
Also, x-grafana-id is a JWT signed by Grafana for the user’s identity, not your provider’s token. Decode it to see which claims it contains before relying on it for scope checks.
(tried to make a reply before but it seems to have been blocked, maybe because I tried to include too much log)
Hi @infofcc3 , thank you a lot for your strong and helpful response.
To test oauth access token forwarding I:
login as admin, delete the test user (just in case), log out
login using generic oauth
immediately reach for Explore tab and use the labels dropdown which initiates a request to ask for available labels
So I should not fall in the circumstances you mentioned, I also did not see any of the log patterns you gave me, the only odd log that seems worth mentioning (I previously included the whole login log segment but the answer disappeared):
logger=user.sync t=2026-11-06T14:52:02.75111564Z level=warn msg="The SAML catalog used for this login has an incorrect version format" catalogVersion=
logger=context userId=0 orgId=0 uname= t=2026-11-06T14:52:02.751329706Z level=info msg="Request Completed" method=GET path=/login/generic_oauth status=302 remote_addr=172.128.1.1 time_ms=68 duration=68.439707ms size=24 referer=http://localhost:3000/ handler=/login/:name status_source=server
The SAML warn seems odd as I use OIDC, not SAML…
I anyone has a clue on what I may have missed that prevent access token from being forwarded? That would help me a lot.
I also want to mention that I audit the headers being forwarded to loki using a mitmproxy, worth mentioning because in similar posts I saw several people trying to see the headers using browser debugging console, which is obviously not able to the what is happening between Grafana data source proxy and the datasource.
Before concluding that Grafana omitted the token, where was this header list captured: at the proxy ingress, or on the request the proxy forwarded to Loki? The presence of x-grafana-* headers does not distinguish those two cases.
For one Explore query made by the OAuth user, compare only the presence or absence of Authorization and X-ID-Token at both hops, without logging their values. If they arrive at the proxy but disappear downstream, check its header forwarding/authentication configuration first. That would narrow the search before changing Grafana’s OAuth settings.