How can I get the Token of OAuth?

I am using aws cognito (OAuth) to login. I wanted to get the token that was generated when the user logs in at Reatjs, and make some request for some services at AWS. so, the question is how can I get the token using a grafana plugin?

1 Like

I’m facing the same issue than John. I’ve configured my Grafana server to allow users to connect via our identity platform (using OAuth2), and now I’d like to use the user’s access token in our datasource backend plugin. Is this token exposed somewhere?
Thanks for your help!

1 Like

I’ve been reading the grafana’s code to know where it keeps the Token it takes from OAuth, and I found it but I think, it’s not saving anywhere.

here is the code where the grafana handles the Token:

I think to do what we want I think we need to use this:
“Enable token authentication” https://grafana.com/docs/grafana/latest/developers/plugins/add-authentication-for-data-source-plugins/#enable-token-authentication

maybe, we have to prepare an OAuth server that supports “OAuth 2.0 Client Credentials Grant”. and authenticate the puglin request. I’m still investigating about that.

https://oauth.net/2/grant-types/client-credentials/#:~:text=The%20Client%20Credentials%20grant%20type,to%20access%20a%20user’s%20resources.

Using the “Enable token authentication” I wrote before I was able to authenticate my request. but I have no way of identifying which user is logged in.
I am asking another question here Is there any way to pass a Global variables on a route?
If I can find a solution for topic above, I think this topic will be solved as well.

I am trying to do something similar –
I have grafana configured to use my Fief OAuth2 identity provider, but while it logs in just fine, it seems to be loosing the accessToken that I would want to hit the backend JSON API for that user’s data.