AnsweredAssumed Answered

Getting 20014 - Authentication failed error

Question asked by 33471 on May 3, 2013
Latest reply on May 3, 2013 by 22662

     Hi Guys,

     I just started using Marketo API. Created simple client for accessing leads. I have followed the documentation to create my request. SOAP request is as follows.

     <?xml version='1.0' encoding='UTF-8'?>
     <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
         <soapenv:Header>
             <ns1:AuthenticationHeader xmlns:ns1="http://www.marketo.com/mktows/">
                 <mktowsUserId>
                    XXXXXXXXXXXXXX
                 </mktowsUserId>
                 <requestSignature>
                     XXXXXXXXXXXXXX
                 </requestSignature>
                 <requestTimestamp>
                     2013-05-03T14:24:11-08:00
                 </requestTimestamp>
             </ns1:AuthenticationHeader>
         </soapenv:Header>
         <soapenv:Body>
             <ns1:paramsGetLead xmlns:ns1="http://www.marketo.com/mktows/">
                 <leadKey>
                     <keyType>EMAIL</keyType>
                     <keyValue>testuser1700@gmail.com</keyValue>
                 </leadKey>
             </ns1:paramsGetLead>
         </soapenv:Body>
     </soapenv:Envelope>  

     The mktowsUserId and URL Endpoint are correct, I have checked it. I am using following code to generate signature

         public static String calculateHMAC(String data, String timeStamp, String key)
         throws java.security.SignatureException
         {
             String result;
             try {
                 
                 SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), HMAC_SHA1_ALGORITHM);
             
                 Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM);
                 mac.init(signingKey);
             
                 String signatureData = timeStamp.concat(data);
                             
                 byte[] rawHmac = mac.doFinal(signatureData.getBytes());
             
                 result = DatatypeConverter.printBase64Binary(rawHmac);            
             
             } catch (Exception e) {
             throw new SignatureException("Failed to generate HMAC : " + e.getMessage());
             }
             return result;
         }

      

     I am not sure what is wrong, Could you guys please check my request and signature generation method are correct or not?

     Thanks.

      

      

Outcomes