Directus: Add API Auth Details to Docs

Created on 3 Dec 2020  路  4Comments  路  Source: directus/directus

Most helpful comment

Yes, with examples, it would be great !
This new version seems cool, but suffer a cruel lack of documentation

All 4 comments

Yes, with examples, it would be great !
This new version seems cool, but suffer a cruel lack of documentation

I would love to find some documentation on how to get user data after login, (i.e. email, name, etc...). The login success response only returns tokens and an expiration, and there is no documentation on how to use those tokens to retrieve user data.

Hello ! You can get the users datas using this endpoint: /users/me as described here

As for the Token returned after Auth, you need to pass it in the header of your request.

Here is how i did it in JS to get datas about the logged-in user:

const headers = {
      "Content-type": "application/json",
      "Authorization": "Bearer " + <Your Auth Token>,
}

let res = await fetch('http://192.168.99.102:8055/users/me', {headers});
let json = await res.json();

It return a json response.

Do not forget to configure directus with the right authorizations

Hello ! You can get the users datas using this endpoint: /users/me as described here

As for the Token returned after Auth, you need to pass it in the header of your request.

Here is how i did it in JS to get datas about the logged-in user:

const headers = {
      "Content-type": "application/json",
      "Authorization": "Bearer " + <Your Auth Token>,
}

let res = await fetch('http://192.168.99.102:8055/users/me', {headers});
let json = await res.json();

It return a json response.

Do not forget to configure directus with the right authorizations

Awesome, thank you! I must've glazed right over that in the docs!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pvshum picture pvshum  路  4Comments

benhaynes picture benhaynes  路  4Comments

dfgkzhang picture dfgkzhang  路  4Comments

rijkvanzanten picture rijkvanzanten  路  3Comments

dimitrov-adrian picture dimitrov-adrian  路  3Comments