本文整理汇总了Java中oauth.signpost.commonshttp.CommonsHttpOAuthProvider类的典型用法代码示例。如果您正苦于以下问题:Java CommonsHttpOAuthProvider类的具体用法?Java CommonsHttpOAuthProvider怎么用?Java CommonsHttpOAuthProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CommonsHttpOAuthProvider类属于oauth.signpost.commonshttp包,在下文中一共展示了CommonsHttpOAuthProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMockedClient
import oauth.signpost.commonshttp.CommonsHttpOAuthProvider; //导入依赖的package包/类
private OAuthClient getMockedClient() throws Exception {
when(properties.getProperty("consumerKey")).thenReturn("key");
when(properties.getProperty("consumerSecret")).thenReturn("secret");
final FileInputStream fileInputStreamMock = PowerMockito.mock(FileInputStream.class);
PowerMockito.whenNew(FileInputStream.class).withArguments(Matchers.anyString())
.thenReturn(fileInputStreamMock);
PowerMockito.whenNew(CommonsHttpOAuthConsumer.class).withArguments(Matchers.anyString(), Matchers.anyString())
.thenReturn(CommonsHttpOAuthConsumerMock);
PowerMockito.whenNew(CommonsHttpOAuthProvider.class).withArguments(Matchers.anyString(), Matchers.anyString(), Matchers.anyString())
.thenReturn(CommonsHttpOAuthProviderMock);
Config config = new Config(properties);
OAuthClient client = new OAuthClient(config);
return client;
}
示例2: setHttpClient
import oauth.signpost.commonshttp.CommonsHttpOAuthProvider; //导入依赖的package包/类
/**
* Use a specific {@link HttpClient} for HTTP traffic.
*
* @param httpClient
* {@link HttpClient}, that is used for HTTP communication
*/
public synchronized void setHttpClient( HttpClient httpClient )
{
this.httpClient = httpClient;
// register HTTP client in the OAuth provider
try
{
OAuthProvider p = getAuthProvider();
if (p instanceof CommonsHttpOAuthProvider)
{
((CommonsHttpOAuthProvider) p).setHttpClient( httpClient );
}
}
catch (OAuthNotAuthorizedException ex)
{
}
}
示例3: getProvider
import oauth.signpost.commonshttp.CommonsHttpOAuthProvider; //导入依赖的package包/类
private OAuthProvider getProvider() {
// use our http client that accepts self-signed certificates
DefaultHttpClient httpclient = MySSLSocketFactory.getNewHttpClient();
// Use the provider bundled with signpost, the android libs are buggy
// See: http://code.google.com/p/oauth-signpost/issues/detail?id=20
OAuthProvider provider = new CommonsHttpOAuthProvider(
requestTokenUrl,
accessTokenUrl,
authorizeUrl,
httpclient);
provider.setOAuth10a(oauth10a);
return provider;
}
示例4: onCreate
import oauth.signpost.commonshttp.CommonsHttpOAuthProvider; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
System.setProperty("debug", "true");
this.consumer = new CommonsHttpOAuthConsumer(OAuthConstants.CONSUMER_KEY, OAuthConstants.CONSUMER_SECRET);
this.provider = new CommonsHttpOAuthProvider(
OAuthConstants.REQUEST_URL + "?scope=" + URLEncoder.encode(OAuthConstants.SCOPE, OAuthConstants.ENCODING),
OAuthConstants.ACCESS_URL + "?scope=" + URLEncoder.encode(OAuthConstants.SCOPE, OAuthConstants.ENCODING),
OAuthConstants.AUTHORIZE_URL);
} catch (Exception e) {
Log.e(TAG, "Error creating consumer / provider",e);
}
Log.i(TAG, "Starting task to retrieve request token.");
new OAuthRequestTokenTask(this,consumer,provider).execute();
}
示例5: IOSTwitterAPI
import oauth.signpost.commonshttp.CommonsHttpOAuthProvider; //导入依赖的package包/类
public IOSTwitterAPI(TwitterConfig config) {
super(config);
consumer = new CommonsHttpOAuthConsumer(config.TWITTER_CONSUMER_KEY, config.TWITTER_CONSUMER_SECRET);
provider = new CommonsHttpOAuthProvider("https://api.twitter.com/oauth/request_token", "https://api.twitter.com/oauth/access_token",
"https://api.twitter.com/oauth/authorize");
}
示例6: onCreate
import oauth.signpost.commonshttp.CommonsHttpOAuthProvider; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mIntent = this.getIntent();
consumerKey = mIntent.getStringExtra("TWITTER_CONSUMER_KEY");
consumerSecret = mIntent.getStringExtra("TWITTER_CONSUMER_SECRET");
callbackURL = mIntent.getStringExtra("TWITTER_CALLBACK_URL");
// transporterFilename = mIntent.getStringExtra("STORAGE_FILENAME");
consumer = new CommonsHttpOAuthConsumer(consumerKey, consumerSecret);
provider = new CommonsHttpOAuthProvider("https://api.twitter.com/oauth/request_token", "https://api.twitter.com/oauth/access_token",
"https://api.twitter.com/oauth/authorize");
/**
* we delete all existing knowledge of this user and assume he canceled
* the signin process.
*/
AndroidTwitterAuthIntent.TWITTER_USER_TOKEN = null;
AndroidTwitterAuthIntent.TWITTER_USER_TOKEN_SECRET = null;
AndroidTwitterAuthIntent.TWITTER_SIGNIN_CANCELED = true;
if (mIntent.getData() == null) {
try {
(new RetrieveRequestTokenTask()).execute(new Void[0]);
} catch (Exception e) {
Gdx.app.log(TAG, e.getMessage());
throw new RuntimeException(e);
}
}
}
示例7: DesktopTwitterAPI
import oauth.signpost.commonshttp.CommonsHttpOAuthProvider; //导入依赖的package包/类
public DesktopTwitterAPI(TwitterConfig config) {
super(config);
consumer = new CommonsHttpOAuthConsumer(config.TWITTER_CONSUMER_KEY, config.TWITTER_CONSUMER_SECRET);
provider = new CommonsHttpOAuthProvider("https://api.twitter.com/oauth/request_token", "https://api.twitter.com/oauth/access_token",
"https://api.twitter.com/oauth/authorize");
}
示例8: prepareRequestToken
import oauth.signpost.commonshttp.CommonsHttpOAuthProvider; //导入依赖的package包/类
public void prepareRequestToken() {
try {
consumer = new CommonsHttpOAuthConsumer(twitterConsumerKey, twitterConsumerSecret);
provider = new CommonsHttpOAuthProvider(SocialConstants.TWITTER_REQUEST_URL,SocialConstants.TWITTER_ACCESS_URL,SocialConstants.TWITTER_AUTHORIZE_URL);
} catch (Exception e) {
//Log.e(TAG, "Error creating consumer / provider",e);
SessionEvents.onLoginError("Error", SessionListenerType.TWITTER_SESSION_LISTENER);
}
//Log.i(TAG, "Starting task to retrieve request token.");
provider.setOAuth10a(true);
}
示例9: FiveHundredPxOAuthHelper
import oauth.signpost.commonshttp.CommonsHttpOAuthProvider; //导入依赖的package包/类
public FiveHundredPxOAuthHelper(String consumerKey, String consumerSecret) {
if (TextUtils.isEmpty(consumerKey) || TextUtils.isEmpty(consumerSecret)) {
throw new IllegalArgumentException(getClass().getSimpleName() + " must be started with" +
"a non-empty consumerKey and consumerSecret");
}
mOAuthConsumer = new CommonsHttpOAuthConsumer(consumerKey, consumerSecret);
mOAuthProvider = new CommonsHttpOAuthProvider(REQUEST_TOKEN_URL,
ACCESS_TOKEN_URL, AUTHORIZE_URL);
}
示例10: buildOAuthProvider
import oauth.signpost.commonshttp.CommonsHttpOAuthProvider; //导入依赖的package包/类
@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 );
}
示例11: init
import oauth.signpost.commonshttp.CommonsHttpOAuthProvider; //导入依赖的package包/类
private void init() throws Exception {
CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer(
this.consumerKey, this.consumerSecret);
CommonsHttpOAuthProvider provider = new CommonsHttpOAuthProvider(
request_token_url, access_token_url, authorize_url);
final String urlString = provider.retrieveRequestToken(consumer, "");
this.requestOauthToken = HttpParameterUtil.getUrlParamValue(urlString,
"oauth_token");
this.requestOauthSecret = consumer.getTokenSecret();
}
示例12: RetrieveAccessTokenTask
import oauth.signpost.commonshttp.CommonsHttpOAuthProvider; //导入依赖的package包/类
public RetrieveAccessTokenTask(OpenStreetMapUpload activity,
CommonsHttpOAuthProvider oAuthProvider,
CommonsHttpOAuthConsumer oAuthConsumer,
String verifier) {
this.activity = activity;
this.oAuthProvider = oAuthProvider;
this.oAuthConsumer = oAuthConsumer;
this.verifier = verifier;
}
示例13: RetrieveRequestTokenTask
import oauth.signpost.commonshttp.CommonsHttpOAuthProvider; //导入依赖的package包/类
public RetrieveRequestTokenTask(Context context,
CommonsHttpOAuthProvider oAuthProvider,
CommonsHttpOAuthConsumer oAuthConsumer, String callbackUrl) {
this.context = context;
this.oAuthProvider = oAuthProvider;
this.oAuthConsumer = oAuthConsumer;
this.callbackUrl = callbackUrl;
}
示例14: getProvider
import oauth.signpost.commonshttp.CommonsHttpOAuthProvider; //导入依赖的package包/类
public CommonsHttpOAuthProvider getProvider(android.content.Context context ) {
//System.setProperty("debug", "true");
final String scope = Consts.GMAIL_SCOPE + " " + Consts.CONTACTS_SCOPE;
return new CommonsHttpOAuthProvider(
String.format("https://www.google.com/accounts/OAuthGetRequestToken" +
"?scope=%s&xoauth_displayname=%s",
urlEncode(scope),
urlEncode(context.getString(R.string.app_name))),
"https://www.google.com/accounts/OAuthGetAccessToken",
"https://www.google.com/accounts/OAuthAuthorizeToken?btmpl=mobile") {
{ setOAuth10a(true); }
};
}
示例15: buildProvider
import oauth.signpost.commonshttp.CommonsHttpOAuthProvider; //导入依赖的package包/类
/**
* Builds an {@see OAuthProvider} based on these parameters and a OAuth consumer <code>consumer</code>.
*
* @return the provider
* @throws IllegalArgumentException thrown if consumer is null
*/
public OAuthProvider buildProvider() throws IllegalArgumentException {
return new CommonsHttpOAuthProvider(
requestTokenUrl,
accessTokenUrl,
authoriseUrl
);
}