Can't create user API token using WHM/cPanel API
Hi everybody.
We're developing a 3rd part app using whm/cpanel API. We have to set up a fully automated process of creating cPanel accounts and generating API tokens to be able to trigger cpanel functions via API. We faced the issue of generating token, here are the steps we're trying to accomplish (GET):
1. That successfully creates a cpanel user (whm API):
https://{{example_hostname}}.servconfig.com:2087/json-api/createacct?api.version=1&username={{exampleuser}}&domain={{example_user}}.com
2. That successfully creates cpanel user session (whm API):
https://{{example_hostname}}.servconfig.com:2087/create_user_session ?api.version=1&user={{example_user}}&service=cpaneld
3. This is where we got stuck on trying to create an API token (cpanel API):
https://{{example_hostname}}.servconfig.com:2083/{{cpsess1234567890 - generated from previous step}}/execute/Tokens/create_full_access?name={{example_token_name}}
Trying to use this cpsess1234567890 instead of BasicAuth as there's no API token generated yet, but getting nothing (user login html) in response.
Hope for your help guys
-
I did have a link for the relevant API docs in my earlier reply, but it did format it in a way that maybe led you to not click on it? Here it is without the (bad) preview: https://api.docs.cpanel.net/whm/use-whm-api-to-call-cpanel-api-and-uapi/
0 -
Thank you Thomas, that worked :) 0 -
Hey all, hey Thomas! Thanks again for the previous reply, cPanel tokens are being generated correctly Now got stuck with the Token creation but on the WHM level :( Can you advise please on how to generate that token before the WHM is created? But let me explain in more detailed first. We're actually creating cPanel account under WHM level (using 'createacct' API) with the "reseller" privileges so that WHM account has been created automatically (if I understand that correctly). And then we need to generate an API token to use regular WHM API endpoints for that account, but I don't understand what auth parameters I should use. "cp_security_token" token doesn't work either And the same for WHM ROOT API token. Is this possible to generate both with that type of WHM? 0
Please sign in to leave a comment.
Comments
6 comments