Metabase API Authentication

Hello,

I’m trying to authenticate using api/session/google_auth via Postman.

But I don’t know what information I am supossed to set to param token .

Can somebody help me?

Thanks

1 Like

Solved requesting api/session

Hey can you help answer this?
I am trying to use the metabase API to get data into a google sheet (without making the question public)

Can you help?

Hey manghat!

Sure.

My problem was that the account I was trying to authenticate was configured to authenticate via Google SSO.

So, first set up an account where you can authenticate using only its email and password.

Then, you need to request Metabase API to authenticate.. like this:

Finally, use this endpoint to get question results:

When you make this second request... You must provide X-Metabase-Session header with the value retrived from first request (session endpoint)...Example:

You need any help, let me know :slight_smile:

1 Like

Just to make it easier for everyone, here’s the links:
https://github.com/metabase/metabase/wiki/Using-the-REST-API
https://github.com/metabase/metabase/blob/master/docs/api-documentation.md

2 Likes

Thanks flamber :slight_smile:

Thank you Gustavo!

1 Like

Hey Gustavo,

Would you mind sharing the actual app script code? :see_no_evil: I am a mood developer and have been trying to do a URL request, but it has not been working.
This is what I tried :

function myFunction() {
  var url = "https://metabaseurl.com/api/session";
  var headers = {
             "contentType": "application/json",
             "body":{"username": "email", "password": "password"}
             };

  var response = UrlFetchApp.fetch(url, headers);
  var text = response.getResponseCode();
  Logger.log(text);
}

If it understand correctly, i need to get this response and then submit another request for that specific query I want the data of. I am unable to get a response from the above code on app script. :frowning:

PS: also, what happens if I want to use some filters for the same query?

@manghat I’m pretty sure sending body inside of headers is not actually seen as the body, but rather as a header called body.
Most other frameworks calls it payload - but I don’t know what “mood” is, perhaps you should link to that framework/language.

The best way to learn the API, is to just use Metabase while having your browser developer Network-tab open and looking at the request, and what data is being send/received.

Hey @manghat,

Do you still need help?

Sorry for the delay to answer…

My account was linked to my last company email and I left there before the July 12th (when you answered asking for help). So I was not able to receive any notification.

Regards,

Gustavo