cpanel-UAPI-php-class
cpanel-UAPI-php-class copied to clipboard
Is it possible to use WHM API Token instead of cPanel password to authenticate?
@medusared It currently doesn't but it has been on my list to work something out. I expect i need to split authentication into its own class as i have some more 2FA stuff to do anyway. Could do with throwing something into Composer too i expect.
Reopened this to mark as an enhancement - will remind me to look at it as soon as i can.
Hey,
Did you ever get a chance to look into this?
@Laim Honestly, no. I've been so busy with other bits and pieces that its just not happened.
If its something you can do and you would like to, i'm happy to accept pull requests etc, otherwise it'll get done when i have time but god knows when that will be!
I have added it to my classes (might not be the best way but it works, hope it helps you too):
- Added a class variable called usecpaneltoken
- changed the construct to include a parameter to use cpanel tokens (the password then becomes the token)
- changed code in curl_request
In the class declaration: protected $usecpaneltoken = FALSE;
changed __construct: function __construct($user, $pass, $server, $secret = FALSE, $usecpaneltoken = FALSE) { $this->usecpaneltoken = $usecpaneltoken;
in function curl_request if($this->usecpaneltoken) { $httpHeaders = array("Authorization: cpanel " . base64_decode($this->auth)); } else { $httpHeaders = array("Authorization: Basic " . $this->auth); }