OkHttp Signpost

Signpost extension for signing OkHttp requests

Лицензия

Лицензия

Группа

Группа

se.akerfeldt
Идентификатор

Идентификатор

okhttp-signpost
Последняя версия

Последняя версия

1.1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

OkHttp Signpost
Signpost extension for signing OkHttp requests
Ссылка на сайт

Ссылка на сайт

http://github.com/pakerfeldt/okhttp-signpost/
Система контроля версий

Система контроля версий

http://github.com/pakerfeldt/okhttp-signpost

Скачать okhttp-signpost

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/se.akerfeldt/okhttp-signpost/ -->
<dependency>
    <groupId>se.akerfeldt</groupId>
    <artifactId>okhttp-signpost</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/se.akerfeldt/okhttp-signpost/
implementation 'se.akerfeldt:okhttp-signpost:1.1.0'
// https://jarcasting.com/artifacts/se.akerfeldt/okhttp-signpost/
implementation ("se.akerfeldt:okhttp-signpost:1.1.0")
'se.akerfeldt:okhttp-signpost:jar:1.1.0'
<dependency org="se.akerfeldt" name="okhttp-signpost" rev="1.1.0">
  <artifact name="okhttp-signpost" type="jar" />
</dependency>
@Grapes(
@Grab(group='se.akerfeldt', module='okhttp-signpost', version='1.1.0')
)
libraryDependencies += "se.akerfeldt" % "okhttp-signpost" % "1.1.0"
[se.akerfeldt/okhttp-signpost "1.1.0"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
com.squareup.okhttp3 : okhttp jar 3.0.0-RC1
oauth.signpost : signpost-core jar 1.2.1.2

Модули Проекта

Данный проект не имеет модулей.

okhttp-signpost

A Signpost extension for signing OkHttp requests.

Download

Gradle:

    compile 'se.akerfeldt:okhttp-signpost:1.1.0'
    compile 'com.squareup.okhttp3:okhttp:3.0.0-RC1'
    compile 'oauth.signpost:signpost-core:1.2.1.2'

Usage

To use, simply create an instance of OkHttpOAuthConsumer passing in your consumer key/secret pair. Set your token and token secret. Lastly, create a SigningInterceptor with your consumer and give it to your OkHttpClient.Builder.

OkHttpOAuthConsumer consumer = new OkHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
consumer.setTokenWithSecret(token, secret);

OkHttpClient client = new OkHttpClient.Builder()
        .addInterceptor(new SigningInterceptor(consumer))
        .build();

The SigningInterceptor is a convenience for signing the request but is not mandatory. You could also sign your request manually like so:

OkHttpOAuthConsumer consumer = ...
Request request = new Request.Builder().build();
Request signedRequest = (Request) consumer.sign(request).unwrap();

Call call = okHttpClient.newCall(signedRequest);

Obviously, this fits very well with Retrofit 2 as well. Just pass your OkHttpClient (containing the interceptor) to Retrofit:

OkHttpOAuthConsumer consumer = new OkHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
consumer.setTokenWithSecret(token, secret);

OkHttpClient client = new OkHttpClient.Builder()
        .addInterceptor(new SigningInterceptor(consumer))
        .build();

return new Retrofit.Builder()
        ...
        .client(okHttpClient)
        .build();

License

Copyright 2015 Patrik Åkerfeldt

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Версии библиотеки

Версия
1.1.0
1.0.0