Jump to content

api Authentication failed error


snake

Recommended Posts

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 ?

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 7 months later...

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