当前位置: 首页>>代码示例>>Java>>正文


Java OkHttpOAuthConsumer.setTokenWithSecret方法代码示例

本文整理汇总了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();
}
 
开发者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: 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

示例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();
}
 
开发者ID:Yelp,项目名称:yelp-android,代码行数:19,代码来源:YelpAPIFactory.java

示例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;
}
 
开发者ID:lkorth,项目名称:photo-paper,代码行数:36,代码来源:WallpaperApplication.java


注:本文中的se.akerfeldt.okhttp.signpost.OkHttpOAuthConsumer.setTokenWithSecret方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。