I am trying to login via soap from an external server
$api_url_v2 = "http://www.example.com/api/v2_soap/?wsdl=1";
$username = 'username';
$password = 'password';
$cli = new SoapClient($api_url_v2);
$session_id = $cli->login($username, $password);
The error message I get is Fatal error:
Uncaught SoapFault exception: [2] Access denied
However if I look in the api_user
table in magento db, then the lognum column increments by 1 when I have the correct username / password combo… so it seems like the system knows the details are correct, but is giving me access denied.
The users role I have ticked all options for and assigned the role to the user
I can't seem to see many examples of this issue anywhere.
Has anyone come accross this issue, or can you provide any tips to solve?
Best Answer
Please try this connection code:
I took it from the API Guidlines here: http://www.magentocommerce.com/api/soap/introduction.html#Introduction-SOAPAPIVersionv2
I have also used this method on my stores for product retrieval and editting, however, are you on version 1.6.2? I know there is a role setting bug that doesnt allow you to set all roles.
Suggestions: Provide version number, edition & url if possible.
REVISION:
The above code has just been tested on my server which seems to be succesfull with this result:
Let me know how you get on.