本文整理汇总了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();
}
开发者ID:beraldofilippo,项目名称:TWStreaming,代码行数:24,代码来源:NetworkModule.java
示例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);
}
开发者ID:prestodb-rocks,项目名称:presto-rest,代码行数:17,代码来源:TwitterServiceFactory.java
示例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);
}
开发者ID:jsaund,项目名称:RxUploader,代码行数:25,代码来源:Service.java
示例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);
}
开发者ID:graviton57,项目名称:TheNounProject,代码行数:9,代码来源:NetworkModule.java
示例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();
}
开发者ID:jsaund,项目名称:RxUploader,代码行数:29,代码来源:SampleApplication.java
示例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;
}
开发者ID:Plastix,项目名称:Forage,代码行数:11,代码来源:OAuthInteractor.java
示例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());
}
}
开发者ID:Plastix,项目名称:Forage,代码行数:12,代码来源:OAuthSigningInterceptor.java
示例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();
}
开发者ID:Yelp,项目名称:yelp-android,代码行数:19,代码来源:YelpAPIFactory.java
示例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;
}
开发者ID:lkorth,项目名称:photo-paper,代码行数:36,代码来源:WallpaperApplication.java
示例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);
}
开发者ID:Plastix,项目名称:Forage,代码行数:7,代码来源:OkApiModule.java
注:本文中的se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论