Unathenticated status API

Hello, Im trying to use the API.

I used this endpoint (/api/session) and I got the token/session_id successfully using my username and the temporary password but then I try to use any other endpoint and I got either Response 401 or 404 and it says "Unathenticated".

Im using a selfhosted version of Metabase, I always access with my gmail credentials as SSO.

What Im a missing? How can I authenticate myself?

Hi @alejandradzr
You are trying to authenticate via email/password - not via Google Sign-in, which uses a different endpoint.
It's a lot more complicated to authenticate via Google Sign-in.
I would recommend that you create a dedicated API user, which is just email/password, via Admin > People.

1 Like

I already did it but Im still getting "Unathenticated".

This is my code

response = requests.post('metabaseURL/api/session',
json={'username': 'user@mail.io, 'password': 'password'})
session_id = response.json()['id']
print(response.json())
headers = {'Content-Type': 'application/json',
'X/Metabase-Session': session_id}
publicCard = requests.get('metabaseURL/api/card/', headers=headers)

response gives me a 200 status.
publicCard gives me a 401 error status.

@alejandradzr It's not X/Metabase-Session, it's X-Metabase-Session:
https://www.metabase.com/learn/administration/metabase-api