In Progress CPANEL-42869 - Misleading documentation for WHM::api_token_update

malex

Member
Mar 13, 2017
10
0
51
France
cPanel Access Level
Root Administrator
Hi,

The documentation for the WHM api_token_update is misleading.

The documentation give the following example to assign multiple ACL to a single Token :

Code:
Assign multiple privilges.

acl=acl-0=create-acct acl-1=list-accts acl-2=kill-acct
This is incorrect, the first acl= is not needed, as you can see if I try to run the following command :

Code:
[root@cheeseburger ~]# whmapi1 api_token_create token_name=cp-bug acl=acl-0=create-acct acl-1=list-accts acl-2=kill-acct
---
data: {}

metadata:
  command: api_token_create
  reason: "The system failed to create the API token: Invalid or unauthorized ACL specified: acl-0=create-acct"
  result: 0
  version: 1
The correct syntax (so without acl=) is :

Code:
[root@cheeseburger ~]# whmapi1 api_token_create token_name=cp-bug acl-1=basic-whm-functions acl-2=create-acct
---
data:
  acls:
    - basic-whm-functions
    - create-acct
  create_time: '1685542950'
  expires_at: ~
  name: cp-bug
  token: BR1G00DLUCKTRYINGTH1ST0K3NZK61Z8
metadata:
  command: api_token_create
  reason: OK
  result: 1
  version: 1
EDIT: The same bug applies to the IP whitelisting.

Please update the documentation. The same syntax apply using the Curl API.
And provide a real example too, the CURL/CLI example is a lazy one...
 

cPanelThomas

Developer
Feb 16, 2023
38
29
93
cPanel
cPanel Access Level
Root Administrator
Probably an oversight when bulk conversion of the old API docs to swagger/openapi was done. Sorry about this. There's a way to get those $NAME-0,1,2... params to work right, but it looks like that did not happen for these ones.

I've filed it as a bug, tracked internally as CPANEL-42869
 
  • Like
Reactions: cPRex