Export to GitHub

oauth - issue #245

oauth_problem_advice: Failed to validate signature


Posted on Mar 19, 2014 by Happy Elephant

This's my code in Maventproject

public void testKey() { try {

    XeroClient xeroClient = null;
    xeroClient = new XeroClient(endpointUrl, consumerKey, consumerSecret, praviteKey);

    xeroClient.postContacts();
} catch (Exception e) {
    // TODO: handle exception
    e.printStackTrace();
}

}

public void postContacts() { try {

    String postXML = "<Contact>" + "<Name>Contact Name</Name>" + "<ContactNumber>002</ContactNumber>" + "</Contact>";
    OAuthClient client = new OAuthClient(new HttpClient3());
    OAuthAccessor accessor = buildAccessor();
    OAuthMessage m = client.invoke(accessor, OAuthMessage.PUT, endpointUrl + "Contacts", OAuth.newList("xml", postXML));
    System.out.println(OAuthMessage.readAll(m.getBodyAsStream(), "UTF-8"));
} catch (Exception e) {
    // TODO: handle exception
    e.printStackTrace();
}

}

pom.xml <repositories> <repository> <id>oauth</id> <name>OAuth Repository</name> <url>https://code.google.com/p/oauth/source/detail?r=1236</url&gt; </repository> </repositories>

<dependency> <groupId>net.oauth.core</groupId> <artifactId>oauth</artifactId> <version>20100527</version> </dependency> <dependency> <groupId>net.oauth.core</groupId> <artifactId>oauth-consumer</artifactId> <version>20100527</version> </dependency> <dependency> <groupId>net.oauth.core</groupId> <artifactId>oauth-httpclient3</artifactId> <version>20090617</version> </dependency>

Output: Unable to respond to any of these challenges: {oauth=OAuth Realm="14.161.2.13"} 11:35:41.954 [http-8080-1] DEBUG httpclient.wire.content - << "oauth_problem=signature_invalid&oauth_problem_advice=Failed%20to%20validate%20signature" net.oauth.OAuthProblemException: signature_invalid oauth_problem_advice: Failed to validate signature

Status: New