snake Posted March 8, 2015 Share Posted March 8, 2015 I have a small App I have written, which works fine against the original WHMCS I wrote it for as well as my dev installation. I have recently tried to run the exact same code against a different WHMCS installation and I now get "Authentication failed" and I cannot see why. I have verified the following multiple times. 1. the adminapi user password is correct, I have reset it 3 times (copy and paste) to be sure, no there are no spaces in it. 2. the user DOES have API access 3. yes I have updated the login details in my code and I am using the correct username/password URL etc 4. yes my IP address has been allowed in the general settings. I presume the password is being MD5 hashed properly being as the same code works fine against other WHMCS installation. Anyone got any other ideas why I would be getting this error ? 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted March 8, 2015 Share Posted March 8, 2015 Could you post the script that you are using? 0 Quote Link to comment Share on other sites More sharing options...
snake Posted March 8, 2015 Author Share Posted March 8, 2015 sure, here it is <cfhttp url="#application.whmcs.api.url#" method="post" charset="utf-8"> <cfhttpparam name="action" value="addclient" type="formfield"> <cfhttpparam type="formfield" name="responsetype" value="json"> <cfhttpparam name="username" value="#application.whmcs.api.username#" type="formfield"> <cfhttpparam name="password" value="#hash(application.whmcs.api.password,'MD5')#" type="formfield"> <cfhttpparam name="password2" value="#password#" type="formfield"> <cfloop collection="#mappings#" item="field"> <!--- generate all the fields to submit to the API ---> <cfif mappings[field] neq ""> <cfif application.whmcs.Fields[mappings[field]].isCustomField> <cfhttpparam name="customfield[#application.whmcs.fields[mappings[field]].id#]" value="#getUsers[field]#" type="formfield"> <cfset api.request[#field#] = "customfield[#application.whmcs.fields[mappings[field]].id#]) = #getUsers[field]#"> <cfelse> <cfhttpparam name="#lcase(mappings[field])#" value="#getUsers[field]#" type="formfield"> <cfset api.request[mappings[field]] = "#getUsers[field]#"> </cfif> </cfif> </cfloop> <!--- the required fields from the form ---> <cfif form.skipvalidation is true> <cfhttpparam name="skipvalidation" value="true" type="formfield"> </cfif> <cfhttpparam type="formfield" name="customfield[21]" value="#form.enableSMS#"> <cfif form.sendWelcomeEmail is false> <cfhttpparam type="formfield" name="noemail" value="true"> </cfif> <cfif form.groupId NEQ 0> <cfhttpparam type="formfield" name="groupid" value="#form.groupID#"> </cfif> </cfhttp> 0 Quote Link to comment Share on other sites More sharing options...
snake Posted March 8, 2015 Author Share Posted March 8, 2015 OK I have done the the simplest test possible http://domain1.com/includes/api.php?username=apiuser&password=apipassword&action=getclients This works perfectly against site 1 but fails against site2, with the authentication failed message. Again I have confirmed 100% that the username/password is correct, as I can login to the whmcs admin with it. In fact I also tried with my own admin login, which also has API access, and that also fails. they are both running WHMCS 5.3.11 0 Quote Link to comment Share on other sites More sharing options...
snake Posted March 8, 2015 Author Share Posted March 8, 2015 solved it, the MD5 password has to be in lower case. 0 Quote Link to comment Share on other sites More sharing options...
ephost Posted October 18, 2015 Share Posted October 18, 2015 solved it, the MD5 password has to be in lower case. Thank you. This was driving me crazy. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.