本文整理汇总了Java中se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer类的典型用法代码示例。如果您正苦于以下问题:Java OkHttpOAuthConsumer类的具体用法?Java OkHttpOAuthConsumer怎么用?Java OkHttpOAuthConsumer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OkHttpOAuthConsumer类属于se.akerfeldt.okhttp.signpost包,在下文中一共展示了OkHttpOAuthConsumer类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: signingInterceptor
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer; //导入依赖的package包/类
@Provides
@TheNounProjectAppScope
public SigningInterceptor signingInterceptor(){
OkHttpOAuthConsumer consumer = new OkHttpOAuthConsumer(
BuildConfig.NOUN_DEV_API_KEY,
BuildConfig.NOUN_DEV_SECRET_API_KEY);
return new SigningInterceptor(consumer);
}
示例5: authorize
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer; //导入依赖的package包/类
@NonNull
public static Completable authorize() {
final OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
final HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(Config.HTTP_LOG_LEVEL);
httpClient.addInterceptor(loggingInterceptor);
final OkHttpOAuthConsumer consumer =
new OkHttpOAuthConsumer(Config.CONSUMER_KEY, Config.CONSUMER_SECRET);
final XOAuthProvider provider =
new XOAuthProvider(Config.REQUEST_TOKEN_URL, Config.ACCESS_TOKEN_URL,
Config.AUTH_CALLBACK_URL, httpClient.build());
return Observable.fromCallable(
() -> provider.retrieveRequestToken(consumer, Config.AUTH_CALLBACK_URL))
.flatMap(__ -> {
try {
provider.retrieveAccessToken(consumer, "");
} catch (@NonNull Exception e) {
Observable.error(e);
}
token = consumer.getToken();
secret = consumer.getTokenSecret();
return Observable.empty();
})
.toCompletable();
}
示例6: OAuthInteractor
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer; //导入依赖的package包/类
@Inject
public OAuthInteractor(OkHttpOAuthProvider okHttpOAuthProvider,
OkHttpOAuthConsumer okHttpOAuthConsumer,
@OAuthUserToken StringPreference userToken,
@OAuthUserTokenSecret StringPreference userTokenSecret) {
this.okHttpOAuthProvider = okHttpOAuthProvider;
this.okHttpOAuthConsumer = okHttpOAuthConsumer;
this.userToken = userToken;
this.userTokenSecret = userTokenSecret;
}
示例7: 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());
}
}
示例8: 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();
}
示例9: 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;
}
示例10: provideOkHttpOAuthConsumer
import se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer; //导入依赖的package包/类
@NonNull
@Provides
@Singleton
public static OkHttpOAuthConsumer provideOkHttpOAuthConsumer() {
return new OkHttpOAuthConsumer(BuildConfig.OKAPI_US_CONSUMER_KEY, BuildConfig.OKAPI_US_CONSUMER_SECRET);
}