public interface SphereAccessTokenSupplier extends AutoCloseable, Supplier<CompletionStage<String>>
See also TokensFacade
if you just want to fetch an access token for one time.
Modifier and Type | Method and Description |
---|---|
void |
close() |
CompletionStage<String> |
get()
Returns the OAuth access token.
|
static SphereAccessTokenSupplier |
ofAutoRefresh(SphereAuthConfig config,
HttpClient httpClient,
boolean closeHttpClient)
Provides a token generator which tries to always provide a valid token.
|
static SphereAccessTokenSupplier |
ofConstantToken(String token)
Provides a token generator which just returns a fixed token, so the client is only usable
for the live time of this token.
|
static SphereAccessTokenSupplier |
ofOneTimeFetchingToken(SphereAuthConfig config,
HttpClient httpClient,
boolean closeHttpClient)
Provides a token generator which fetches only one token.
|
CompletionStage<String> get()
get
in interface Supplier<CompletionStage<String>>
void close()
close
in interface AutoCloseable
static SphereAccessTokenSupplier ofAutoRefresh(SphereAuthConfig config, HttpClient httpClient, boolean closeHttpClient)
config
- the configuration to fetch a tokenhttpClient
- used http clientcloseHttpClient
- set to true, if the httpClient should be closed with the created SphereAccessTokenSupplierstatic SphereAccessTokenSupplier ofConstantToken(String token)
token
- the token which will be passed to the clientstatic SphereAccessTokenSupplier ofOneTimeFetchingToken(SphereAuthConfig config, HttpClient httpClient, boolean closeHttpClient)
config
- the configuration to fetch a tokenhttpClient
- used http client, will be closed with this generator on close()
closeHttpClient
- set to true, if the httpClient should be closed with the created SphereAccessTokenSupplier