Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Authenticating with access hash instead of reseller password with cPanel API2

Discussion in 'cPanel Developers' started by devel, Feb 10, 2014.

  1. devel

    devel Member

    Sep 21, 2013
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Reseller Owner

    I am trying to extract disk and bandwidth usage from cPanel accounts under a reseller. To this end, I am using the cPanel API2 StatsBar->stats->display. The problem I am having is authenticating. When I use the reseller password to log in to any account below the reseller, everything works fine. However, this seems like a bad solution as opposed to using access hashes. But when using the access hash of the reseller account instead (located in /home/reseller/.accesshash), I get access denied errors.

    Could anyone tell me what I am doing wrong? Am I not supposed to be using access hashes here? Is the use of reseller passwords the advocated and approved solution?

    Thanks a lot. My code is below.


    		$cpCfg = array('cpanel' => array('service' => array('cpanel' => array(
    			'host' => 'ip goes here',
    			'user' => 'any cPanel account goes here',
    			//'password' => 'reseller password goes here'
    			'accesshash' => $access-hash-without-newlines-goes-here
    		$cp = Cpanel_PublicAPI::getInstance($cpCfg);
    		$queryMF = array(
    			'module' => 'StatsBar',
    			'function' => 'stat',
    		$queryArgs = array(
    			'display' => 'diskusage|bandwidthusage'
    		$response = $cp->cpanel_api2_request('cpanel', $queryMF, $queryArgs);
    		echo '<pre>'.print_r($response, true).'</pre>';
  2. vanessa

    vanessa Well-Known Member

    Sep 26, 2006
    Likes Received:
    Trophy Points:
    Virginia Beach, VA
    cPanel Access Level:
    DataCenter Provider
    Using an access hash tends to be the preferred solution. It looks like you're using the public API here, correct?

    From first glance, the issue I see is that you're connecting to cPanel as the reseller with the access hash. The access hash only grants access over WHM, not cPanel. Therefore in this particular case, your only option is to use the password.

    You do also have the ability to make the API2 call over WHM instead, which iirc is supported in the Perl version of the public API.

    cPanel XML and JSON APIs
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Apr 11, 2011
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Root Administrator
    Hello :)

    Yes, you must use the password in the scenario you described. We don't support cPanel access with the root/reseller override using any other mechanism at this time.

    Thank you.
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice