
pl.wrzasq.commons.client.interceptor.BearerTokenAuthorizer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-client Show documentation
Show all versions of commons-client Show documentation
Web services client building utilities.
// Generated by delombok at Thu Apr 04 00:08:20 UTC 2019
/*
* This file is part of the pl.wrzasq.commons.
*
* @license http://mit-license.org/ The MIT license
* @copyright 2017, 2019 © by Rafał Wrzeszcz - Wrzasq.pl.
*/
package pl.wrzasq.commons.client.interceptor;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.http.HttpHeaders;
/**
* Feign request interceptor that injects custom HTTP authorization with Bearer token.
*/
public class BearerTokenAuthorizer implements RequestInterceptor {
/**
* Bearer token prefix.
*/
private static final String TYPE_BEARER = "Bearer ";
/**
* HTTP access token..
*/
private String token;
/**
* {@inheritDoc}
*/
@Override
public void apply(RequestTemplate requestTemplate) {
// set the same value as incoming request to execute requests on behalf of the user
requestTemplate.header(HttpHeaders.AUTHORIZATION, BearerTokenAuthorizer.TYPE_BEARER + this.token);
}
@SuppressWarnings("all")
@lombok.Generated
public BearerTokenAuthorizer(final String token) {
this.token = token;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy