Oauth on android problem


Last Updated:

  1. Radzell

    Radzell Member This Topic's Starter

    Joined:
    Jul 5, 2009
    Messages:
    7
    Likes Received:
    0
    I need code review i keep getting a error in the emulator


    Code (Text):
    1. private void authpost(String verificationCode) throws OAuthMessageSignerException, OAuthNotAuthorizedException, OAuthExpectationFailedException, OAuthCommunicationException, IOException{
    2.         /*Creates a consumer object and configure it with access
    3.          * token and token secret still needed from service I HAVE NO IDEA
    4.          * WHAT THEY ARE*/
    5.          
    6.         OAuthConsumer consumer = new CommonsHttpOAuthConsumer(  
    7.                 CONSUMER_KEY, CONSUMER_SECRET, SignatureMethod.HMAC_SHA1);  
    8.           Log.i("cliqdroid", "Finished consumer loading function");
    9.           consumer.setTokenWithSecret(ACCESS_TOKEN, TOKEN_SECRET);
    10.          
    11.        
    12.         //Http request to the protected resource
    13.         URL url = new URL("https://api.cliqset.com/200905/user/radzell/profile");
    14.         HttpURLConnection request = (HttpURLConnection) url.openConnection();
    15.        
    16.         //sign the request so it can get past the security
    17.         consumer.sign(request);
    18.        
    19.         //send the request to the server in order to obtain access to resource
    20.         request.connect();
    21.        
    22.         String responsecode = request.getResponseMessage();
    23.        
    24.         Log.i("Cliqdroid", responsecode);
    25.        
    26.         // create a new service provider object and configure it with
    27.         // the URLs which provide request tokens, access tokens, and
    28.         // the URL to which users are sent in order to grant permission
    29.         // to your application to access protected resources
    30.        
    31.         OAuthProvider provider = new DefaultOAuthProvider(consumer,
    32.                 REQUEST_TOKEN_ENDPOINT_URL, ACCESS_TOKEN_ENDPOINT_URL,
    33.                 AUTHORIZE_WEBSITE_URL);
    34.        
    35.          // fetches a request token from the service provider and builds
    36.         // a url based on AUTHORIZE_WEBSITE_URL and CALLBACK_URL to
    37.         // which your app must now send the user
    38.         @SuppressWarnings("unused")
    39.         String url1 = provider.retrieveRequestToken(OAuth.OUT_OF_BAND);
    40.        
    41.         provider.retrieveAccessToken(verificationCode);
    42.        
    43.        
    44.     }
     

    Advertisement

Share This Page

Loading...