OauthCommunicationException...error

Put your problem here if it does not fit any of the other categories.

OauthCommunicationException...error

Postby shiataz » Mon Nov 15, 2010 2:13 am

I get this error when I run my app (atm the all I am trying to do is get the Oauth to work before I start adding code to actually do something with the authorization. What does this error mean and why do you guys think I might be getting it?

error: system.err oauth_signpost.exception.OauthCommunicationException: Communication with the service provider failed: Host is unresolved.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package hattrick.ass;
  2.  
  3. import oauth.signpost.OAuth;
  4. import oauth.signpost.OAuthProvider;
  5. import oauth.signpost.basic.DefaultOAuthProvider;
  6. import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer;
  7. import oauth.signpost.exception.OAuthCommunicationException;
  8. import oauth.signpost.exception.OAuthExpectationFailedException;
  9. import oauth.signpost.exception.OAuthMessageSignerException;
  10. import oauth.signpost.exception.OAuthNotAuthorizedException;
  11. import android.app.Activity;
  12. import android.content.Intent;
  13. import android.net.Uri;
  14. import android.os.Bundle;
  15. import android.util.Log;
  16. import android.view.View;
  17. import android.widget.Button;
  18. import android.widget.Toast;
  19.  
  20. public class oauthtest extends Activity {
  21.        
  22.         private CommonsHttpOAuthConsumer httpOauthConsumer;
  23.         private OAuthProvider httpOauthprovider;
  24.         public final static String consumerKey =                "**";
  25.         public final static String consumerSecret =     "**";
  26.        
  27.         private static String ACCESS_KEY = null;
  28.         private static String ACCESS_SECRET = null;
  29.        
  30.         private final String CALLBACKURL = "myapp://mainactivity";
  31.        
  32.         private static CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer(
  33.                         consumerKey, consumerSecret);
  34.                         private static OAuthProvider provider = new DefaultOAuthProvider(
  35.                         "http://chpp.hattrick.org/oauth/request_token.ashx", "http://chpp.hattrick.org/oauth/access_token.ashx", "http://chpp.hattrick.org/oauth/authorize.aspx");
  36.         private Button btnLogin;                       
  37.     /*
  38.      *
  39.      * OnCreate method for class
  40.      */
  41.     @Override
  42.     public void onCreate(Bundle savedInstanceState) {
  43.         super.onCreate(savedInstanceState);
  44.         setContentView(R.layout.main);
  45.         btnLogin = (Button) findViewById(R.id.btnLogin);
  46.         btnLogin.setOnClickListener(new View.OnClickListener() {
  47.     @Override
  48.         public void onClick(View v) {
  49.             try {
  50.                  String authURL = provider.retrieveRequestToken(
  51.         consumer, CALLBACKURL);
  52.  
  53.         Log.d("myapp", authURL);
  54.         startActivity(new Intent(Intent.ACTION_VIEW, Uri
  55.         .parse(authURL)));
  56.             } catch (OAuthMessageSignerException e) {
  57.         e.printStackTrace();
  58.             } catch (OAuthNotAuthorizedException e) {
  59.         e.printStackTrace();
  60.             } catch (OAuthExpectationFailedException e) {
  61.         e.printStackTrace();
  62.             } catch (OAuthCommunicationException e) {
  63.         e.printStackTrace();
  64.             }
  65.           }
  66.         });
  67.  
  68.         Uri uri = this.getIntent().getData();
  69.  
  70.         if (uri != null && uri.toString().startsWith(CALLBACKURL)) {
  71.         Log.d("myapp", uri.toString());
  72.         String verifier = uri.getQueryParameter(OAuth.OAUTH_VERIFIER);
  73.         Log.d("myapp", verifier);
  74.         try {
  75.  
  76.         provider.retrieveAccessToken(consumer, verifier);
  77.         ACCESS_KEY = consumer.getToken();
  78.         ACCESS_SECRET = consumer.getTokenSecret();
  79.  
  80.         Log.d("myapp", ACCESS_KEY);
  81.         Log.d("myapp", ACCESS_SECRET);
  82.  
  83.         } catch (OAuthMessageSignerException e) {
  84.         e.printStackTrace();
  85.         } catch (OAuthNotAuthorizedException e) {
  86.         e.printStackTrace();
  87.         } catch (OAuthExpectationFailedException e) {
  88.         e.printStackTrace();
  89.         } catch (OAuthCommunicationException e) {
  90.         e.printStackTrace();
  91.         }
  92.         }
  93.         }
  94.  
  95.  
  96.     }
Parsed in 0.044 seconds, using GeSHi 1.0.8.4


Any help would be greatly appreciated. Thank you
shiataz
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Nov 15, 2010 1:19 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 13 guests