本文整理汇总了Java中se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer.setTokenWithSecret方法的典型用法代码示例。如果您正苦于以下问题:Java OkHttpOAuthConsumer.setTokenWithSecret方法的具体用法?Java OkHttpOAuthConsumer.setTokenWithSecret怎么用?Java OkHttpOAuthConsumer.setTokenWithSecret使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer
的用法示例。
在下文中一共展示了OkHttpOAuthConsumer.setTokenWithSecret方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: provideCall
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer; //导入方法依赖的package包/类
@Provides
@Singleton
Retrofit provideCall() {
OkHttpOAuthConsumer consumer = new OkHttpOAuthConsumer(App.getTwitterKey(),
App.getTwitterSecret());
consumer.setTokenWithSecret(
App.getApplicationInstance().getTwitterSession().getAuthToken().token,
App.getApplicationInstance().getTwitterSession().getAuthToken().secret);
Retrofit.Builder builder =
new Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(GsonConverterFactory.create())
.addConverterFactory(ScalarsConverterFactory.create())
.addCallAdapterFactory(RxJavaCallAdapterFactory.create());
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(new SigningInterceptor(consumer))
.addNetworkInterceptor(new StethoInterceptor())
.build();
return builder.client(client).build();
}
示例2: createService
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer; //导入方法依赖的package包/类
public static TwitterService createService(String consumerKey, String consumerSecret, String token, String secret)
{
OkHttpOAuthConsumer consumer = new OkHttpOAuthConsumer(consumerKey, consumerSecret);
consumer.setTokenWithSecret(token, secret);
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(new SigningInterceptor(consumer))
.build();
return new Retrofit.Builder()
.baseUrl("https://api.twitter.com/1.1/")
.addConverterFactory(JacksonConverterFactory.create())
.client(client)
.build()
.create(TwitterService.class);
}
示例3: createService
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer; //导入方法依赖的package包/类
@NonNull
private static <S> S createService(@NonNull Class<S> s, @NonNull String token,
@NonNull String secret) {
final GsonConverterFactory serializer = GsonConverterFactory.create(
new GsonBuilder().registerTypeAdapterFactory(JSONModelTypeAdapterFactory.create())
.create());
final OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
OkHttpOAuthConsumer consumer = new OkHttpOAuthConsumer(
Config.CONSUMER_KEY, Config.CONSUMER_SECRET);
consumer.setTokenWithSecret(token, secret);
httpClient.addInterceptor(new SigningInterceptor(consumer));
final HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(Config.HTTP_LOG_LEVEL);
httpClient.addInterceptor(loggingInterceptor);
final Retrofit client = new Retrofit.Builder().baseUrl(Config.HOST)
.addConverterFactory(serializer)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.client(httpClient.build())
.build();
return client.create(s);
}
示例4: OAuthSigningInterceptor
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer; //导入方法依赖的package包/类
@Inject
public OAuthSigningInterceptor(OkHttpOAuthConsumer consumer,
@OAuthUserToken StringPreference userToken,
@OAuthUserTokenSecret StringPreference userTokenSecret) {
this.consumer = consumer;
// Set the signing token and secret if we already have one saved in shared prefs
if (userToken.isSet() && userTokenSecret.isSet()) {
consumer.setTokenWithSecret(userToken.get(), userTokenSecret.get());
}
}
示例5: YelpAPIFactory
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer; //导入方法依赖的package包/类
/**
* Construct a new {@code YelpAPIFactory}.
*
* @param consumerKey the consumer key.
* @param consumerSecret the consumer secret.
* @param token the access token.
* @param tokenSecret the token secret.
* @see <a href="https://www.yelp.com/developers/manage_api_keys">https://www.yelp.com/developers/manage_api_keys</a>
*/
public YelpAPIFactory(String consumerKey, String consumerSecret, String token, String tokenSecret) {
OkHttpOAuthConsumer consumer = new OkHttpOAuthConsumer(consumerKey, consumerSecret);
consumer.setTokenWithSecret(token, tokenSecret);
this.httpClient = new OkHttpClient.Builder()
.addInterceptor(new SigningInterceptor(consumer))
.addInterceptor(new ErrorHandlingInterceptor())
.build();
}
示例6: getApiClient
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer; //导入方法依赖的package包/类
public static FiveHundredPxClient getApiClient() {
if (sApiClient == null) {
Realm realm = Realm.getDefaultInstance();
OkHttpClient.Builder okHttpBuilder = new OkHttpClient.Builder();
if (User.isUserLoggedIn(realm)) {
AccessToken accessToken = User.getLoggedInUserAccessToken(realm);
OkHttpOAuthConsumer consumer = new OkHttpOAuthConsumer(BuildConfig.CONSUMER_KEY,
BuildConfig.CONSUMER_SECRET);
consumer.setTokenWithSecret(accessToken.getToken(), accessToken.getTokenSecret());
okHttpBuilder.addInterceptor(new SigningInterceptor(consumer));
} else {
okHttpBuilder.addInterceptor(new ConsumerApiKeyInterceptor());
}
okHttpBuilder.addInterceptor(new UserAgentInterceptor());
if (BuildConfig.DEBUG) {
okHttpBuilder.addNetworkInterceptor(DebugUtils.getDebugNetworkInterceptor());
}
sApiClient = new Retrofit.Builder()
.baseUrl("https://api.500px.com/v1/")
.addConverterFactory(GsonConverterFactory.create(new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.create()))
.client(okHttpBuilder.build())
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(FiveHundredPxClient.class);
realm.close();
}
return sApiClient;
}