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; }
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(); }
/** * 获得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; }
/** * Returns the access token secret. * * @return the access token secret. */ public String getTokenSecret() { return consumer.getTokenSecret(); }
// verifier parametro oauth_verifier della query public void retrieveAccessToken(String verifier) throws ThoundsOAuthParameterExcepion, ThoundsConnectionException { retrieveAccessToken(verifier, consumer.getToken(), consumer.getTokenSecret()); }
public Token getAccessToken() { accessToken = new Token(httpOauthConsumer.getToken(), httpOauthConsumer.getTokenSecret()); return accessToken; }