Admin Guide¶
This section provides documentation for administrators managing the FinAutCRM API system.
Creating API Clients¶
To create a new API client, you can use the create_crm_client.py management command. Run the following command in your prod terminal (company ID 2265 is Testfirma):
/srv/www/crm$ python manage.py create_crm_client \
--name=<client-name> \
--company-id=2265
Target database: DEVELOPMENT
================================================================================
OAuth2 Client Created Successfully!
================================================================================
Client Name: crmapi-bptest10
User ID: 591266
Username: crmapi-bptest10
Group: FINAUTCRM:client
Companies: 2265
Client ID: client_UOwOtfUk0ttAe7IlpDa3WQ
Scopes: read, write
App ID: 29
Client Secret: NzHJuOX5HuNBF-fEZ0T86AkX8AVjjoe9aZrF6Tk-8qQ
Password: xyqk8kkaxk
IMPORTANT: Save these credentials now - they cannot be retrieved later!
Usage Example:
Note
To run the commands below in dev (under wsl), you’ll need to start the
dev server first with (fastapi dev main.py --host 0.0.0.0), then use
ipconfig to find your IPv4 address (likely something like 192.168.91.x),
then finally replace localhost with that IP address in the commands below.
Get access token (on windows you’ll likely need to run this under WSL)
curl -X POST http://localhost:8000/api/v1/auth/token \
-H "Content-Type: application/json" \
-d '{ \
"client_id": "client_UOwOtfUk0ttAe7IlpDa3WQ", \
"client_secret": "NzHJuOX5HuNBF-fEZ0T86AkX8AVjjoe9aZrF6Tk-8qQ", \
"grant_type": "client_credentials", \
"scope": "read write" \
}'
Use the token (you need to modify this command and insert the token from the previous response)
curl -X GET http://localhost:8000/api/v1/orgunits
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
The Client ID and Client Secret should be sent to the customer securely (different channels etc.).
It’s always a good idea to run the curl commands to verify that the client works as expected before sending the credentials to the customer.