Skip to main content
May 3, 2013
Question

Getting 20014 - Authentication failed error

  • May 3, 2013
  • 2 replies
  • 1079 views

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.

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

May 3, 2013

I was able to resolve it. I was doing Base64 encoding, but It requires Hex encoding.

Thanks.

 

May 4, 2013
Easier to debug if you send the full src.  You could try the following to see if the request goes through

byte[] rawHmac = mac.doFinal(signatureData.getBytes());
 
// HHMAC bytes as HEX encoded string
char[] hexChars = Hex.encodeHex(rawHmac);
result = new String(hexChars);