How can I get user details via the user api key?

I am able to auth the user and get the user api key by following this instruction:
https://meta.discourse.org/t/user-api-keys-specification/48536

But I also want to get the user info, because the authentication is done on the web page above, I don’t know the user name or id. They are not returned from the callback URL.

I am wondering if there is an api for me to pass back the user api key and returns the user details? I just need the user id or user name.

1 Like

You should be able to make a request for /session/current.json, which will give you the current user information. Make sure you request the session scope when creating the key.

8 Likes

You can probably also use any of the /my/profile.json URLs, too, if those are included in other scopes.

4 Likes

I cannot get it working. I got page does not exist response. I put the user api key in the header User-Api-Key.
David Taylor’s solution works for me. But it will be good yours is working as well as I don’t need to request session scope.