Jump to content

API credentials are invalid


Jake

Recommended Posts

I'm having a problem connecting to the API.  

I have setup an API key and user.  I am trying to connect to the API via the following code:


           

            $User   = "my_user_Name";
            $Key    = "My_key";
            $Url    = "My_url";

            $this->blestaapi->SetVariables($Url, $User, $Key);
       
            $Response = $this->blestaapi->get("users", "get", array('user_id' => 3));

            print_r($Response->response());
            print_r($Response->errors());

I had to change the API file just a bit because the way my application is setup to initialize the class before I can pass the username and key.  So I created a setter method to do that. The Blesta API class now looks like this:

 

	public function __construct() {}
        
        public function SetVariables($url, $user, $key)
        {
            $this->url  = $url;
			$this->user = $user;
			$this->key  = $key;
        }


            When I run the app the error message I get is:

stdClass Object
(
    [user] => stdClass Object
        (
            [valid] => The API user or key appears to be invalid.
        )

)

I have verified that the object does in fact have the username and key with a var dump of the object.  Any Ideas of what the problem could be?
          

Link to comment
Share on other sites

In Blesta, under Settings > System > API Access, you are sure you are using the correct user/key combination? Have you confirmed there are no unexpected spaces before/after either the user or the key?

The error indicates there is no API user match between what you provided via the API SDK and what Blesta has stored in its database table `api_keys`. You can check that table to be sure the user/key are identical to what you are passing via the API.

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.

Loading...
×
×
  • Create New...