Login with cfx.re/fivem?

Is it possible to create a “login with cfx.re” button, similar to “login with google” or “login with steam” or “login with discord”, where user gets directed to login here on the forums, and has to authorize my app, or if they’ve already done both of those, gets redirected back to my app, and my app can access information about the users account? eg. name, email, id?

1 Like

See

1 Like

Maybe I’m blind but where do I get the api key?

There are no api keys, the user is redirected back to your app with a user api key in the url.

Thank you. I’ve just figured that out, and built a url constructor, and everything is working wonderfully now. I’ll probably release a resource for others to use once I better figure this out, so others don’t have any trouble using this service :smiley:

Any chance you know how to get the user information? I really only want the user’s id, but discourse’s api documentation seems to be lacking, not just for the admin api, but the user one too.

On google, I found /session/current.json
but, using the scopes [read,session_info] it returns “User ID was null” but if I open the same url in my browser it returns all my user infomation (so the url should work in theory?)

1 Like

To get the current user you need to request the /session/current.json endpoint (like you already found out). It requires the session_info scope, make sure you added the User-Api-Key header to the request.

Also getting the user info only requires the session_info scope so please only request that scope if you don’t need anything else.

Old snippet of my code Discourse user-api-keys decryption · GitHub

Honorable Indra, does the game already include this particular identifier when asked for the player identifiers? If not, would you happen to know of a lua example of requesting / returning this user identifier?

The fivem: identifier contains the forum id, use
https://policy-live.fivem.net/api/getUserInfo/(id) to get the forum username.

https://policy-live.fivem.net/api/getUserInfo/72150

I’ve successfully decrypted the response from the /user-api-key/new and obtained the api key (along with the nonce I passed in, and the api version), and when i make a request to https://forum.cfx.re/session/current.json with the User-Api-Key: {payload.key} header I get back User ID was null

I’ve tried this with all three versions of scopes [read], [session_info], and [read,session_info] and all of them return the same.

Disregard. Something must be wrong with my code, because I can make the request in postman with the header no problem.

Edit: For anyone who comes across this page, wondering why you get a user id was null when using lower level curl tools, such as bash curl or php curl, make sure you include a user-agent header as well as the user-api-key header