Exemplo n.º 1
0
 public void authorize(String url)
     throws OAuthMessageSignerException, OAuthNotAuthorizedException,
         OAuthExpectationFailedException, OAuthCommunicationException {
   String verifier = Uri.parse(url).getQueryParameter(oauth.signpost.OAuth.OAUTH_VERIFIER);
   httpOauthprovider.retrieveAccessToken(httpOauthConsumer, verifier);
   accessToken = new Token(httpOauthConsumer.getToken(), httpOauthConsumer.getTokenSecret());
   authentified = true;
 }
Exemplo n.º 2
0
  public void getAccessToken()
      throws OAuthMessageSignerException, OAuthNotAuthorizedException,
          OAuthExpectationFailedException, OAuthCommunicationException {

    provider.setOAuth10a(true);
    provider.retrieveAccessToken(consumer, verifier);
    this.access_token = consumer.getToken();
    this.access_token_secret = consumer.getTokenSecret();
  }
Exemplo n.º 3
0
 /**
  * 获得AccessToken
  *
  * @param intent
  * @return UserInfo
  */
 public User getAccessToken(Intent intent) {
   Uri uri = intent.getData();
   // 处理获取返回的oauth_verifier参数
   String verifier = uri.getQueryParameter(oauth.signpost.OAuth.OAUTH_VERIFIER);
   try {
     httpOauthprovider.setOAuth10a(true);
     httpOauthprovider.retrieveAccessToken(httpOauthConsumer, verifier);
   } catch (OAuthMessageSignerException ex) {
     ex.printStackTrace();
   } catch (OAuthNotAuthorizedException ex) {
     ex.printStackTrace();
   } catch (OAuthExpectationFailedException ex) {
     ex.printStackTrace();
   } catch (OAuthCommunicationException ex) {
     ex.printStackTrace();
   }
   SortedSet<String> user_id = httpOauthprovider.getResponseParameters().get("user_id");
   String userToken = httpOauthConsumer.getToken();
   String userSecret = httpOauthConsumer.getTokenSecret();
   User user = new User(user_id.first(), userToken, userSecret);
   return user;
 }
Exemplo n.º 4
0
 /**
  * Returns the access token secret.
  *
  * @return the access token secret.
  */
 public String getTokenSecret() {
   return consumer.getTokenSecret();
 }
Exemplo n.º 5
0
 // verifier parametro oauth_verifier della query
 public void retrieveAccessToken(String verifier)
     throws ThoundsOAuthParameterExcepion, ThoundsConnectionException {
   retrieveAccessToken(verifier, consumer.getToken(), consumer.getTokenSecret());
 }
Exemplo n.º 6
0
 public Token getAccessToken() {
   accessToken = new Token(httpOauthConsumer.getToken(), httpOauthConsumer.getTokenSecret());
   return accessToken;
 }