WaQas Posted April 17, 2011 Share Posted April 17, 2011 Hello everyone, i try to use API with http but i getting Authentication Failed message.. I do all setup 1. add IP address 2. Admin have right to access API.. but fail to solve the problem.. http://www.yourdomain.com/whmcs/includes/api.php?username=User&password=67f7d93669a0e7d705fe96c7cd7&action=getsupportstatuses&responsetype=xml <?xml version="1.0" encoding="utf-8"?> <whmcsapi version="4.4.2"> <action></action> <result>error</result> <message>Authentication Failed</message> </whmcsapi> ANYONE help me out... 0 Quote Link to comment Share on other sites More sharing options...
jeremyhaber Posted April 19, 2011 Share Posted April 19, 2011 The request is hitting the server correctly and not producing a 404 error. This means that your permissions are wrong or your code is wrong. Are you sure you added the right domain ip to WHMCS API and granted your users API access? Mind sharing the API request call script you are using to get this result? It would help us, help you resolve the problem. 0 Quote Link to comment Share on other sites More sharing options...
WaQas Posted April 19, 2011 Author Share Posted April 19, 2011 The request is hitting the server correctly and not producing a 404 error. This means that your permissions are wrong or your code is wrong. Are you sure you added the right domain ip to WHMCS API and granted your users API access? Mind sharing the API request call script you are using to get this result? It would help us, help you resolve the problem. Hello sir, Please change the path of yours WHMCS... and you will get the result.. 0 Quote Link to comment Share on other sites More sharing options...
cmsplushosting Posted July 23, 2011 Share Posted July 23, 2011 Hello sir,Please change the path of yours WHMCS... and you will get the result.. I have the same problem, with the allowed IP address in the General > Security settings. (one ip per line, and I tried just the single IP of the user whos testing the API) Language vb.net Dim WHMCSClient As New WebClient() Dim form As New NameValueCollection() form.Add("username", "admin") form.Add("password", "12345") form.Add("action", "getsupportstatuses") form.Add("responsetype", "xml") Dim responseData As Byte() = WHMCSClient.UploadValues("http://mysite.com/includes/api.php", form) Dim pass As String = "12345" TextBox1.Text = String.Format("{0}", Encoding.ASCII.GetString(responseData)) Returns: <?xml version="1.0" encoding="utf-8"?> <whmcsapi version="4.5.2"> <action>getsupportstatuses</action> <result>error</result> <message>Authentication Failed</message> </whmcsapi> 0 Quote Link to comment Share on other sites More sharing options...
jeremyhaber Posted July 23, 2011 Share Posted July 23, 2011 I have the same problem, with the allowed IP address in the General > Security settings. (one ip per line, and I tried just the single IP of the user whos testing the API) Language vb.net Dim WHMCSClient As New WebClient() Dim form As New NameValueCollection() form.Add("username", "admin") form.Add("password", "12345") form.Add("action", "getsupportstatuses") form.Add("responsetype", "xml") Dim responseData As Byte() = WHMCSClient.UploadValues("http://mysite.com/includes/api.php", form) Dim pass As String = "12345" TextBox1.Text = String.Format("{0}", Encoding.ASCII.GetString(responseData)) Returns: <?xml version="1.0" encoding="utf-8"?> <whmcsapi version="4.5.2"> <action>getsupportstatuses</action> <result>error</result> <message>Authentication Failed</message> </whmcsapi> Desktop applications are a whole different ball game. You maybe sending your computers IP rather then your internet IP which could cause the error you are getting. As well I hope you are MD5-ing your passwords before they are sent. You may benefit from using the OAuth addon available on my site. This will remove the IP limitation. OAuth returns json rather than XML. I am sure their is a json library available for vb.net somewhere. 0 Quote Link to comment Share on other sites More sharing options...
cmsplushosting Posted July 24, 2011 Share Posted July 24, 2011 Does the system need an MD5 crypted password? That could be reason why it's not working. I am sending as a normal HTTP post, and Crypting the local storage. (usign a higher crypto ie. rijaendal) and the internet ip is the one showing up in HTTP logs. (so all is good there). 0 Quote Link to comment Share on other sites More sharing options...
cmsplushosting Posted July 24, 2011 Share Posted July 24, 2011 Modified my code, the system requires that you send an MD5 hashed password to the API,otherwise it will not work in plaintext. --- Works just great now. Resolved. form.Add("username", My.Settings.WHMCSUser.ToString()) 'Requires MD5 hash form.Add("password", Md5Hash(Crypto.RijndaelSimple.Decrypt(My.Settings.WHMCSPass.ToString(), "5123123123zxczxc!@#", "5123123ASD@", "SHA1", 2, "5585885885852428", 256))) Public Shared Function Md5Hash(ByVal pass As String) As String Dim md5 As System.Security.Cryptography.MD5 = MD5CryptoServiceProvider.Create() Dim dataMd5 As Byte() = md5.ComputeHash(Encoding.[Default].GetBytes(pass)) Dim sb As New StringBuilder() For i As Integer = 0 To dataMd5.Length - 1 sb.AppendFormat("{0:x2}", dataMd5(i)) Next Return sb.ToString() End Function 0 Quote Link to comment Share on other sites More sharing options...
samkelol Posted August 17, 2012 Share Posted August 17, 2012 (edited) Hi have the same issue as you cmsplushosting but I am trying to call the API using a browser. Has anybody been able to get past the Authentication Failed Error. /http://mydomain.co.za/whmcs/includes/api.php?username=api&password=md5hash&action=getclientsproducts&clientid=1&responsetype=xml This is starting to annoy me now, especially since nobody has actually come up with a solution that works. Bottom-line question: Can one call the API from a Browser??? Thanking you in advance for your replies. Edited September 7, 2012 by Infopro 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.