sttp-scribe


Лицензия

Лицензия

Группа

Группа

software.purpledragon
Идентификатор

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

sttp-scribe_2.12
Последняя версия

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

2.0.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

sttp-scribe
sttp-scribe
Ссылка на сайт

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

https://github.com/stringbean/sttp-scribe
Организация-разработчик

Организация-разработчик

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

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

https://github.com/stringbean/sttp-scribe

Скачать sttp-scribe_2.12

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

<!-- https://jarcasting.com/artifacts/software.purpledragon/sttp-scribe_2.12/ -->
<dependency>
    <groupId>software.purpledragon</groupId>
    <artifactId>sttp-scribe_2.12</artifactId>
    <version>2.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/software.purpledragon/sttp-scribe_2.12/
implementation 'software.purpledragon:sttp-scribe_2.12:2.0.2'
// https://jarcasting.com/artifacts/software.purpledragon/sttp-scribe_2.12/
implementation ("software.purpledragon:sttp-scribe_2.12:2.0.2")
'software.purpledragon:sttp-scribe_2.12:jar:2.0.2'
<dependency org="software.purpledragon" name="sttp-scribe_2.12" rev="2.0.2">
  <artifact name="sttp-scribe_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='software.purpledragon', module='sttp-scribe_2.12', version='2.0.2')
)
libraryDependencies += "software.purpledragon" % "sttp-scribe_2.12" % "2.0.2"
[software.purpledragon/sttp-scribe_2.12 "2.0.2"]

Зависимости

compile (5)

Идентификатор библиотеки Тип Версия
org.scala-lang : scala-library jar 2.12.11
org.slf4j : slf4j-api jar 1.7.26
com.softwaremill.sttp.client : core_2.12 jar 2.1.2
com.github.scribejava : scribejava-apis jar 6.9.0
com.github.bigwheel : util-backports_2.12 jar 2.1

test (6)

Идентификатор библиотеки Тип Версия
org.scalatest : scalatest_2.12 jar 3.1.2
org.scalamock : scalamock_2.12 jar 4.4.0
org.scala-lang.modules : scala-collection-compat_2.12 jar 2.1.6
commons-io : commons-io jar 2.7
org.apache.commons : commons-lang3 jar 3.10
ch.qos.logback : logback-classic jar 1.2.3

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

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

sttp-scribe - sttp backend for ScribeJava

Build Status Codacy Grade Test Coverage Maven Central - Scala 2.11 Maven Central - Scala 2.12 Maven Central - Scala 2.13

A backend implementation for sttp that allows you to use ScribeJava as a backend. Now you can call OAuth endpoints using sttp!

Quickstart

Add sttp-scribe, sttp and Scribe to your project:

libraryDependencies ++= Seq(
  "software.purpledragon"         %% "sttp-scribe"      % <version>,
  "com.softwaremill.sttp.client"  %% "core"             % "2.1.2",
  "com.github.scribejava"         %  "scribejava-apis"  % "6.9.0",    
)

Setup your Scribe service:

val service = new ServiceBuilder("api-key")
  .apiSecret("api-secret")
  .callback("http://www.example.com/oauth_callback/")
  .build(GitHubApi.instance());

Create a token provider:

val tokenProvider = new OAuth2TokenProvider() {
  private var currentToken: Option[OAuth2AccessToken] = None

  override def accessTokenForRequest: OAuth2AccessToken = {
    currentToken.getOrElse { 
      // fetch from DB or another source
    }
  }

  override def tokenRenewed(newToken: OAuth2AccessToken): Unit = {
    currentToken = Some(newToken)
    // persist token to DB
  }
}

Then create a ScribeOAuth20Backend and use sttp to make authenticated calls:

implicit val backend: SttpBackend[Identity, Nothing, NothingT] = 
  new ScribeOAuth20Backend(service, tokenProvider)

val response = basicRequest
  .get(uri"https://api.github.com/users/octocat")
  .send()

The Scribe backend will take care of refreshing the access token when it expires and retrying the current API call.

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

Версия
2.0.2
2.0.1
2.0.0
1.6.0
1.5.2
1.5.1
1.5.0
1.4.0
1.3.1
1.3.0
1.2.6
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0