I just found out that WP-toolkit has a rest api.
fantastic... I could really really use it.
I found it by going into WHM -> WP-Toolkit -> Settings- > Open REST API documentation.
in there we see three options:
1. Servers
2. host
3. cpanelOrWhmSecurityToken
I can use this swagger webGUI to make my API calls, and I get the results successfully.
but I cannot for the life of me get this to work outside of WebGUI.... for example if im using Visual Studio Code with REST API extension.
here is what I believe should be the correct way:
first get a Security Token (/0123456789):
to get a security Token, I read in your API doc's I should do this:
GET https://domain.tld:2087/json-api/create_user_session?api.version=1&service=cpaneld&user=[customerCpanelUserName]
Authorization: whm root:[API_TOKEN]
or if you are going to use the WHM server method:
GET https://domain.tld:2087/json-api/create_user_session?api.version=1&service=whostmgrd&user=root
Authorization: whm root:[API_TOKEN]
Calling these api requests, I get a successful response that includes the session_token that looks like this (/0123456789), and some more interesting results... like a SSO url.
ok... so then I should be able to make another API request to the WP-toolkit rest API service using this user_session token ?? correct ??,, something like this:
GET https://domain.tld:2083/0123456789/3rdparty/wpt/index.php/v1/installations?sortBy=title&sortOrder=asc
Accept: application/json
Authorization: Basic [API_TOKEN]
or if you want to make the request to the WHM side:
GET https://domain.tld:2087/0123456789/cgi/wpt/index.php/v1/installations?sortBy=title&sortOrder=asc
Accept: application/json
Authorization: Basic [API_TOKEN]
but no matter what I try, I just cannot make this work...
and I have tried almost everything.
I just get Token denied. and the results are just html.... most of the times just the login screen html.
I have also tried to use Authorization: whm root:[API_TOKEN]....
but I also get Token denied.
I have tried creating a session_token with different API version.. but it does not work.
so.... :
what is the correct way of making requests to the WP-toolkit REST API, remotely ?
authenticating and then making the request it self.
fantastic... I could really really use it.
I found it by going into WHM -> WP-Toolkit -> Settings- > Open REST API documentation.
in there we see three options:
1. Servers
2. host
3. cpanelOrWhmSecurityToken
I can use this swagger webGUI to make my API calls, and I get the results successfully.
but I cannot for the life of me get this to work outside of WebGUI.... for example if im using Visual Studio Code with REST API extension.
here is what I believe should be the correct way:
first get a Security Token (/0123456789):
to get a security Token, I read in your API doc's I should do this:
GET https://domain.tld:2087/json-api/create_user_session?api.version=1&service=cpaneld&user=[customerCpanelUserName]
Authorization: whm root:[API_TOKEN]
or if you are going to use the WHM server method:
GET https://domain.tld:2087/json-api/create_user_session?api.version=1&service=whostmgrd&user=root
Authorization: whm root:[API_TOKEN]
Calling these api requests, I get a successful response that includes the session_token that looks like this (/0123456789), and some more interesting results... like a SSO url.
ok... so then I should be able to make another API request to the WP-toolkit rest API service using this user_session token ?? correct ??,, something like this:
GET https://domain.tld:2083/0123456789/3rdparty/wpt/index.php/v1/installations?sortBy=title&sortOrder=asc
Accept: application/json
Authorization: Basic [API_TOKEN]
or if you want to make the request to the WHM side:
GET https://domain.tld:2087/0123456789/cgi/wpt/index.php/v1/installations?sortBy=title&sortOrder=asc
Accept: application/json
Authorization: Basic [API_TOKEN]
but no matter what I try, I just cannot make this work...
and I have tried almost everything.
I just get Token denied. and the results are just html.... most of the times just the login screen html.
I have also tried to use Authorization: whm root:[API_TOKEN]....
but I also get Token denied.
I have tried creating a session_token with different API version.. but it does not work.
so.... :
what is the correct way of making requests to the WP-toolkit REST API, remotely ?
authenticating and then making the request it self.