//The consumer object was lost because the browser got into foreground, need to instantiate it again with your apps token and secret. consumer = new CommonsHttpOAuthConsumer("xxx", "yyy"); //Set the requestToken and the tokenSecret that you got earlier by calling retrieveRequestToken. consumer.setTokenWithSecret(requestToken, tokenSecret); //The provider object is lost, too, so instantiate it again. provider = new CommonsHttpOAuthProvider("https://api.twitter.com/oauth/request_token", "https://api.twitter.com/oauth/access_token", "https://api.twitter.com/oauth/authorize"); //Now that's really important. Because you don't perform the retrieveRequestToken method at this moment, the OAuth method is not detected automatically (there is no communication with Twitter). So, the default is 1.0 which is wrong because the initial request was performed with 1.0a. provider.setOAuth10a(true); provider.retrieveAccessToken(consumer, verifier);
@Override protected OAuthProvider buildProvider(String requestTokenUrl, String accessTokenUrl, String websiteUrl, boolean mockConnection) throws Exception { if (mockConnection) { CommonHttpOAuthProviderMock provider = new CommonHttpOAuthProviderMock(requestTokenUrl, accessTokenUrl, websiteUrl); provider.mockConnection(OAuth.OAUTH_TOKEN + "=" + TOKEN + "&" + OAuth.OAUTH_TOKEN_SECRET + "=" + TOKEN_SECRET); return provider; } return new CommonsHttpOAuthProvider(requestTokenUrl, accessTokenUrl, websiteUrl); } }
@Override protected OAuthProvider buildOAuthProvider( String apiBaseUrl ) { if (httpClient==null) setDefaultHttpClient(); return new CommonsHttpOAuthProvider( apiBaseUrl + "/security/oauth/request_token", apiBaseUrl + "/security/oauth/access_token", apiBaseUrl + "/security/oauth/confirm_access", httpClient ); }
@Override protected OAuthProvider buildOAuthProvider(String apiBaseUrl) { if (httpClient == null) setDefaultHttpClient(); return new CommonsHttpOAuthProvider( apiBaseUrl + "/security/oauth/request_token", apiBaseUrl + "/security/oauth/access_token", apiBaseUrl + "/security/oauth/confirm_access", httpClient); }
public OAuth(ServiceInfo info, boolean use10a) { this.info = info; this.provider = new CommonsHttpOAuthProvider(info.requestTokenURL, info.accessTokenURL, info.authorizationURL); this.provider.setOAuth10a(use10a); }
public OAuth(ServiceInfo info, boolean use10a) { this.info = info; this.provider = new CommonsHttpOAuthProvider(info.requestTokenURL, info.accessTokenURL, info.authorizationURL); this.provider.setOAuth10a(use10a); }
@Override protected OAuthProvider buildOAuthProvider( String apiBaseUrl ) { if (httpClient==null) setDefaultHttpClient(); return new CommonsHttpOAuthProvider( apiBaseUrl + "/security/oauth/request_token", apiBaseUrl + "/security/oauth/access_token", apiBaseUrl + "/security/oauth/confirm_access", httpClient ); }
mTwitter = new TwitterFactory().getInstance(); mHttpOauthConsumer = new CommonsHttpOAuthConsumer(twitterConsumerKey, twitterSecretKey); mHttpOauthprovider = new CommonsHttpOAuthProvider("https://twitter.com/oauth/request_token", "https://twitter.com/oauth/access_token", "https://twitter.com/oauth/authorize"); try{ authUrl = mHttpOauthprovider.retrieveRequestToken(mHttpOauthConsumer, CALLBACK_URL); }catch(OAuthCommunicationException oACEx){ Log.d("", ""); }catch(OAuthMessageSignerException oAMSEx){ Log.d("", ""); }catch(OAuthNotAuthorizedException oANAEx){ Log.d("", ""); }catch(OAuthExpectationFailedException oAEFEx){ Log.d("", ""); }
//Generate a new oAuthConsumer object commonsHttpOAuthConsumer = new CommonsHttpOAuthConsumer( "Consumer Key", "Consumer Secret Key"); //Generate a new oAuthProvider object commonsHttpOAuthProvider = new CommonsHttpOAuthProvider( "https://www.tumblr.com/oauth/request_token", "https://www.tumblr.com/oauth/access_token", "https://www.tumblr.com/oauth/authorize"); //Retrieve the URL to which the user must be sent in order to authorize the consumer return commonsHttpOAuthProvider.retrieveRequestToken( commonsHttpOAuthConsumer, "Callback URL as registered with Tumblr" );
/** * Constructor. * * @param consumerKey * the consumer key to manager. * @param consumerSecret * the corresponding consumer secret. * @param accessTokenUrl * the URL of the OAuth service's access token endpoint. * @param httpClient * the {@link HttpClient} to use to communicate with the OAuth service. * @throws OAuthException * if an error occurs with one of the OAuth components during initialization. */ public OAuthManager(String consumerKey, String consumerSecret, String accessTokenUrl, HttpClient httpClient) throws OAuthMessageSignerException, OAuthNotAuthorizedException, OAuthExpectationFailedException, OAuthCommunicationException { this(new CommonsHttpOAuthProvider(null, accessTokenUrl, null, httpClient), initConsumer( consumerKey, consumerSecret)); }
private OAuthConsumer consumer; private OAuthProvider provider; ... ... ... provider = new CommonsHttpOAuthProvider ( TWITTER_REQUEST_TOKEN_URL, TWITTER_ACCESS_TOKEN_URL, TWITTER_AUTHORIZE_URL); private void askOAuth() { try { consumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET); provider = new CommonsHttpOAuthProvider("http://twitter.com/oauth/request_token", "http://twitter.com/oauth/access_token", "http://twitter.com/oauth/authorize"); provider.setOAuth10a(true); String authUrl = provider.retrieveRequestToken(consumer, CALLBACK_URL); Toast.makeText(this, "Please authorize this app!", Toast.LENGTH_LONG).show(); this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl))); } catch (Exception e) { Log.e(APP, e.getMessage()); Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); } }
OAuthProvider provider = new CommonsHttpOAuthProvider(YAHOO_REQUEST_TOKEN_URL , YAHOO_ACCESS_TOKEN_URL, YAHOO_AUTHORIZE_URL); provider.setOAuth10a(true); consumer.setTokenWithSecret(yahooToken, yahooTokenSecret); provider = new CommonsHttpOAuthProvider(YAHOO_REQUEST_TOKEN_URL, YAHOO_ACCESS_TOKEN_URL, YAHOO_AUTHORIZE_URL); provider.setOAuth10a(true);
commonsHttpOAuthProvider = new CommonsHttpOAuthProvider(TWITTER_OAUTH_REQUEST_TOKEN_ENDPOINT, TWITTER_OAUTH_ACCESS_TOKEN_ENDPOINT, TWITTER_OAUTH_AUTHORIZE_ENDPOINT); commonsHttpOAuthConsumer = new CommonsHttpOAuthConsumer(getString(R.string.twitter_oauth_consumer_key),
mHttpOauthprovider = new CommonsHttpOAuthProvider("https://twitter.com/oauth/request_token", "https://twitter.com/oauth/access_token", "https://twitter.com/oauth/authorize");
commonsHttpOAuthProvider = new CommonsHttpOAuthProvider(TWITTER_OAUTH_REQUEST_TOKEN_ENDPOINT, TWITTER_OAUTH_ACCESS_TOKEN_ENDPOINT, TWITTER_OAUTH_AUTHORIZE_ENDPOINT); commonsHttpOAuthConsumer = new CommonsHttpOAuthConsumer(getString(R.string.twitter_oauth_consumer_key),
CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET); CommonsHttpOAuthProvider provider = new CommonsHttpOAuthProvider(REQUEST_TOKEN_URL, ACCESS_TOKEN_URL, AUTHORIZE_URL); provider.setOAuth10a(true);
@Override public OAuthProvider getProvider() throws ConnectionException { CommonsHttpOAuthProvider provider = null; provider = new CommonsHttpOAuthProvider(getApiUrl(ApiRoutineEnum.OAUTH_REQUEST_TOKEN), getApiUrl(ApiRoutineEnum.OAUTH_ACCESS_TOKEN), getApiUrl(ApiRoutineEnum.OAUTH_AUTHORIZE)); provider.setHttpClient(ApacheHttpClientUtils.getHttpClient(data.getSslMode())); provider.setOAuth10a(true); return provider; }
protected void onCreate(Bundle savedInstanceState) { consumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET); provider = new CommonsHttpOAuthProvider(REQUEST_TOKEN_URL, ACCESS_TOKEN_URL, AUTHORIZE_WEBSITE_URL); if(getIsAuthorized() == 0) { callOAuth();
this.mainProvider = new CommonsHttpOAuthProvider(REQUEST_TOKEN_ENDPOINT_URL, ACCESS_TOKEN_ENDPOINT_URL, AUTHORIZE_WEBSITE_URL);
"mySecret"); mProvider = new CommonsHttpOAuthProvider ( TWITTER_REQUEST_TOKEN_URL, TWITTER_ACCESS_TOKEN_URL,