cPanel API authentication with security token
Hi everyone. I have been working on a project which will allow users to login to their cpanel account from a third party application. I have successfully used the PHP script to remotely login to the cpanel account and generated a security token from it.
How ever now I want to be able to access the cPanel's much vast API to access its data. I want to use the API with the security token that I have generated, but all the examples seems to use username/password authentication.
I would appreciate it if anyone can point me to a right direction.
Thanks
-
If you have already authenticated and generated your security token the API calls should just work. Use the API shell in either WHM or cPanel to see what the urls generated for API calls are but it should be a near drop in replacement. Ex: API shell will generate this as the url: /execute/Branding/include
With this you just need $serverurl:2083/$sessionToken/$url so the API call is this:https://mytestserver.com:2083/cpsess123456/execute/Branding/include
0 -
If you have already authenticated and generated your security token the API calls should just work. Use the API shell in either WHM or cPanel to see what the urls generated for API calls are but it should be a near drop in replacement. Ex: API shell will generate this as the url:
/execute/Branding/include
With this you just need $serverurl:2083/$sessionToken/$url so the API call is this:https://mytestserver.com:2083/cpsess123456/execute/Branding/include
Thanks for the response. I have generated the security token by using the cPanel's loginmein class for PHP. I first generated the logged in URL from the script found here: gist.github.com/kmark/4440574. From that URL I extracted the security token. Now my problem is that, if I load the URL generated by the script then I can use the security token to make API calls, but since I am just extracting the security token from the URL it is giving me "Access Denied" error. This is because the cookies of the cPanel is not being created. Could you help me further based on the above mentioned details?0 -
Hello, Why do you need security token when you're trying to access cPanel API? REST calls works without any security token. Which programming language are you using? PHP or something else? 0 -
Hi guys, Sorry to jump here, but how can I generate that security token. I have tried several solutions I have found everywhere, but I cannot manage. I can login well. I need to get the security token and redirect user to the awstat page of his website. Thanks for any help you can give me. Kind regards, Darma 0 -
hi i want to use the PHP script to remotely login to the cpanel account and generate a security token from it. do you have a php example ? 0
Please sign in to leave a comment.
Comments
11 comments