WHM API returns Token denied
hi, I am using WHM API to automatically create cPanel accounts. I followed the documentation bu I am facing an issue with the token.
After creating the token in my WMH, I try the URL in the browser but it will only return this error
I am using this line from the API documentation
* I changed all needed details in the URL. * I have created the API token in the WHM. What am I doing wrong here?
{"cpanelresult":{"apiversion":"2","error":"Token denied","data":{"reason":"Token denied","result":"0"},"type":"text"}}
I am using this line from the API documentation
https://hostname.example.com:2087/cpsess##########/json-api/createacct?api.version=1&username=user&domain=example.com&plan=package_name&featurelist=default"a=0&password=12345luggage&ip=n&cgi=1&hasshell=1&contactemail=user%40seconddomain.com&cpmod=paper_lantern&maxftp=5&maxsql=5&maxpop=10&maxlst=5&maxsub=1&maxpark=1&maxaddon=1&bwlimit=500&language=en&useregns=1&hasuseregns=1&reseller=0&forcedns=1&mailbox_format=mdbox&mxcheck=local&max_email_per_hour=500&max_defer_fail_percentage=80&owner=root
* I changed all needed details in the URL. * I have created the API token in the WHM. What am I doing wrong here?
-
Hi, How are you submitting the token via the browser? Also, please link the documentation you and following, and what is the version number of cPanel & WHM you are using? 0 -
Hi, Yes, I am submitting through the browser. This is the documentation I am following: WHM API 1 Functions - createacct - Software Development Kit - cPanel Documentation 0 -
Hi, How are you submitting the token via the browser? Are you adding it to the Authorization header? Are you appending it to the URL? Is there another method you are using? Which version of cPanel & WHM are you using? 0 -
What I do is to change the values in the given URL to my actual values https://hostname.example.com:2087/cpsess##########/json-api/createacct?api.version=1&username=user&domain=example.com&plan=package_name&featurelist=default"a=0&password=12345luggage&ip=n&cgi=1&hasshell=1&contactemail=user%40seconddomain.com&cpmod=paper_lantern&maxftp=5&maxsql=5&maxpop=10&maxlst=5&maxsub=1&maxpark=1&maxaddon=1&bwlimit=500&language=en&useregns=1&hasuseregns=1&reseller=0&forcedns=1&mailbox_format=mdbox&mxcheck=local&max_email_per_hour=500&max_defer_fail_percentage=80&owner=root
I also tryhttps://hostname.example.com:2087/cpsess##########/json-api/createacct?api.version=1
and just paste in the browser and then it gives me this error.{"cpanelresult":{"apiversion":"2","error":"Token denied","data":{"reason":"Token denied","result":"0"},"type":"text"}}
No other way, that's the only way I am using now, because I want to make sure it's working before implementing my code. I am using version: 64.0.250 -
Hi, Thank you for the information. API Token authentication doesn't work via the browser, at least not without using dev tools to modify the request headers. When you submit your test URL the browser should either use your existing session or exit with an error like: "cpanelresult":{"apiversion":"2","error":"Access denied","data":{"reason":"Access denied","result":"0"},"type":"text"}}
Information about using API tokens is in our Guide to API Authentication - API Tokens - Software Development Kit - cPanel Documentation guide. The fact your error message is reporting a problem with the token suggests something else is wrong. Did you happen to mean version 68.0.25? We didn't publish 64.0.25.0
Please sign in to leave a comment.
Comments
5 comments