Access to grafana API with OAuth2.0 user

Hi Everybody,

We currently have our grafana instance integrated with Azure AD via oAuth2.0 protocol.
As per the documentation provided in the following link, it is possible to consume HTTP API using the session cookie generated on the authentication and which can be retrieved using the developers tools in the web browser.

We tried using that cookie using Postman to consume for exmaple the dashboard and organization APIs but we keep getting a 401 unauthorized error and the message “Ivalid API KEY”. It seems as Grafana is trying to recognize the cookie as an API key, but it is not

We also tried to do the same using basic authentication and putting the following format, but with no success.
http://api_key:<session_cookie>@<our_hostname>/api/org

Could you help us on leeting us know which is the right way to access the Grafana API using the oAuth2.0 protocol?

If you have a cookie, then you should submit it with your Postman request as a cookie (see https://learning.postman.com/docs/sending-requests/cookies/), rather than via basic auth or as a bearer token - which seems to be what you’re trying to do.

Basic auth will only work only with your username and password (though I’m not sure if OAuth2 credentials work that way - probably not).

And bearer token authentication will only work with a token that you’ve obtained either from the UI or the API (see Authentication HTTP API | Grafana Labs). The bearer token is, again, separate from your cookie. It’s a long alphanumeric string that will start with “eyJ”.

Hi there @roncallomatias. We are having the same issue, I was wondering if you were able to fix this issue? Thanks!