I have a Java program communicating with a server for authentication and displaying the correct response:

public class Example {

 private static final String PROTECTED_RESOURCE_URL = "http://testwebsite.com/";

  public static void main(String[] args)
  {
    OAuthService service = new ServiceBuilder()
                                .provider(TwoLeggedOAuth.class)
                                .apiKey("my_key")
                                .apiSecret("my_secret")
                                .build();
    Token token = new Token("", "");   
    OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);  
    service.signRequest(token, request);         
    Response response = request.send();            

    System.out.println("Response: " + response.getBody());
   }
}

The same program does not work when integrated into an Android application.
I get the message: oAuth Verification Failed.

有帮助吗?

解决方案

I was trying it with android version 2.2, when I tried with 2.3 it started working.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top