Setting the api key via console

Is there a way to set the main api key via the console?

YML=app
SSH_USER=root@host
API_KEY=`ssh $SSH_USER sudo docker exec -w /var/www/discourse -i $YML rake api_key:get`
2 Likes

Does this get or set the api?

It does both. It sets it if it’s not set already.

Is the api key being passed in and used or is rake api_key:get creating one if one does not exist?

Context is rebuilding an instance and keeping the old api key.

If the database persists then the API key persists.

1 Like

Cool. So it’s in the database somewhere.

Context is building from scratch and testing the importing routines.

Thanks Jay, cheers!

1 Like

Have a look at the rake task in lib/tasks/api_key.

1 Like

Hey @pfaffman, how can I follow these steps inside the app?? I mean after ./launcher enter app, how can I use these commands you mentioned?

Should be able to do just rake api_key:get — give that a go. I haven’t looked at the command so I’m uncertain if there are any parameters you need.

5 Likes

Thanks for your reply, I did solve my problem via this solution here Locked out of admin account after disabling SSO Memberful

Regarding commands, app commands, and so on, where can I learn more about it? It is being tough to find some basic information and hard to solve problems when I need to.

You would

./launcher enter app 
 rake api_key:get

Maybe have a look at Administrative Bulk Operations

3 Likes