zhanrui208 / oauth

Automatically exported from code.google.com/p/oauth
0 stars 0 forks source link

oauth_problem_advice: Failed to validate signature #245

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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>
        </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%20s
ignature"
net.oauth.OAuthProblemException: signature_invalid
oauth_problem_advice: Failed to validate signature

Original issue reported on code.google.com by dieu.ngu...@aoteaglobal.com on 19 Mar 2014 at 4:48