de.otto:oauth-token-filter

A OAuth Token Filter for JAX-RS clients

License

License

GroupId

GroupId

de.otto
ArtifactId

ArtifactId

oauth-token-filter
Last Version

Last Version

1.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

de.otto:oauth-token-filter
A OAuth Token Filter for JAX-RS clients
Project URL

Project URL

https://github.com/otto-de/oauth-token-filter
Source Code Management

Source Code Management

https://github.com/otto-de/oauth-token-filter/tree/master/

Download oauth-token-filter

How to add to project

<!-- https://jarcasting.com/artifacts/de.otto/oauth-token-filter/ -->
<dependency>
    <groupId>de.otto</groupId>
    <artifactId>oauth-token-filter</artifactId>
    <version>1.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/de.otto/oauth-token-filter/
implementation 'de.otto:oauth-token-filter:1.0.3'
// https://jarcasting.com/artifacts/de.otto/oauth-token-filter/
implementation ("de.otto:oauth-token-filter:1.0.3")
'de.otto:oauth-token-filter:jar:1.0.3'
<dependency org="de.otto" name="oauth-token-filter" rev="1.0.3">
  <artifact name="oauth-token-filter" type="jar" />
</dependency>
@Grapes(
@Grab(group='de.otto', module='oauth-token-filter', version='1.0.3')
)
libraryDependencies += "de.otto" % "oauth-token-filter" % "1.0.3"
[de.otto/oauth-token-filter "1.0.3"]

Dependencies

compile (2)

Group / Artifact Type Version
javax.ws.rs : javax.ws.rs-api jar 2.1.1
org.glassfish : javax.json Optional jar 1.0.4

test (3)

Group / Artifact Type Version
junit : junit jar 4.12
org.assertj : assertj-core jar 3.8.0
org.mockito : mockito-core jar 2.23.4

Project Modules

There are no modules declared in this project.

Build

OAuthTokenFilter

The OAuthTokenFilter is a JAX-RS client filter that handles OAuth2 authorization. It

  • filters your requests to a service,
  • adds a OAuth2-Token to your requests,
  • stores the token,
  • checks the token for validity
  • and refreshes the token when necessary.

Installing / Getting started

To include the OAuthTokenFilter in your project, simply add it as a Maven Dependency.

<dependency>
  <groupId>de.otto.oauthtokenfilter</groupId>
  <artifactId>oauth-token-filter</artifactId>
  <version>2.0.1</version>
</dependency>

Initial Configuration

Upon using your ClientBuilder, call

import de.otto.oauthtokenfilter.OAuthTokenFilter;
import jakarta.ws.rs.client.ClientBuilder;
...

ClientBuilder.newBuilder()
 .register(OAuthTokenFilter.builder()
   .username("<yourUsername>")
    .password("<yourPassword>")
    .loginurl("<yourLoginURL>")
    .clientId("<yourClientId>")
    .clientSecret("<yourClientSecret>")
    .tokenLifetimeInSeconds("<yourTokenLifetimeInSeconds>")
    .grant_type("<api_grant_type>")    
    .client(ClientBuilder.newClient());    
    .build())
  .build();

After that, all requests generated by that client will have the proper Authorization Header generated. If the OAuth-server you're working with doesn't need certain values, you can simply leave them out. If you do not specify "grant_type", it will default to "password".

Developing

If you'd like to work on the project, you can do so by running:

git clone https://github.com/otto-de/oauth-token-filter.git

Contributing

If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.

Please follow Google Style formatting.

License

The code in this project is licensed under Apache 2.0 license.

de.otto

OTTO (GmbH & Co. KG)

Versions

Version
1.0.3
1.0.2
1.0.1