Create apikey for user programmatically as admin

Hello everyone, happy halloween and happy holidays.

Is there a way to create an apikey for each user created as an admin, there is User API keys specification which needs user approval , is there a way to create per user apikey programmatically by using admin apikey ?

Thanks in advance.

1 Like

What problem is generating these keys going to solve? Maybe there’s another way and maybe knowing more will suggest a solution.

We are sharing the auth with another site (so that users need not create another account to use discourse) Now in the other webapp, would like to get some (non public) data of users and sometimes post on behalf of user

So you probably want something like DiscourseConnect - Official Single-Sign-On for Discourse (sso).

Or if the app is pulling data from Discourse in the browser then the user will be logged in already. Or if the app is pulling the data in some automated fashion on he backend then you can just use the global key.

Yes thank you for the SSO link, Already done with SSO, we want to post on behalf of users from frontend of our webapp( react app)

So you’re going to want to post from the browser (Is what what “frontend” means?), so they’ll be logged in, so you just need to work out the CORS stuff, I think.

Yes, from the browser. Sorry if I was not clear. This is all happening from another webapp, user isn’t logged in and no iframing of discourse. the request originates from a browser passing the apikey as request Params

My understanding of apikeys is Once we have apikey of user, we can act on behalf of them from anywhere even from a console/terminal (curl or equivalent). No more CORS

3 Likes