Jump to content

API 403 403 Forbidden message=Invalid


Abdelkarim

Recommended Posts

Hi.

 

I'm develop acces to my whcms via API, but I like use Access Control with Access Key according to Developer Docmentacion

Steeps

WHMCS 7.6.1

PHP 7.2

 

Edit my configuration.php and add 

$api_access_key = 'SECRET_KEY_32_CHAR_ASCII127';

I'm using Guzzle 6 for my develop.

$response = $client->get($this->url.self::ENDPOINT, [
    'headers' => [
        'action' => 'GetClients',
        'username' => $this->username, // My API credential identifier
        'password' => $this->password, // My API credentoal secret
        'accesskey' => $this->accesskey, // Acces key on configuration.php
        'responsetype' => self::RESPONSE_TYPE // json
    ]
]);

But when I execute code get exception

GuzzleHttp\Exception\ClientException  : Client error: `GET https://castris.com/intranet/includes/api.php` resulted in a `403 Forbidden` response:
result=error;message=Invalid IP 2.137.134.24

 

What is wrong?
 

 

Link to comment
Share on other sites

An error in understanding the mechanism of sending the parameters, using headers instead of a correct form_params since it is a POST method

Correct code is

 

$response = $client->post($this->url.self::ENDPOINT, [
    'form_params' => [
        'action' => 'GetClients',
        'identifier' => $this->username,
        'secret' => $this->password,
        'accesskey' => $this->accesskey,
        'responsetype' => self::RESPONSE_TYPE
    ]
]);

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated