public abstract class RefreshableTokenSource extends Object implements TokenSource
Calls to getToken() will first check if the token is still valid (currently defined by having at least 10 seconds until expiry). If not, refresh() is called first to refresh the token.
Constructor and Description |
---|
RefreshableTokenSource() |
RefreshableTokenSource(Token token) |
Modifier and Type | Method and Description |
---|---|
Token |
getToken() |
protected abstract Token |
refresh() |
protected static Token |
retrieveToken(HttpClient hc,
String clientId,
String clientSecret,
String tokenUrl,
Map<String,String> params,
Map<String,String> headers,
AuthParameterPosition position)
Helper method implementing OAuth token refresh.
|
protected Token token
public RefreshableTokenSource()
public RefreshableTokenSource(Token token)
protected static Token retrieveToken(HttpClient hc, String clientId, String clientSecret, String tokenUrl, Map<String,String> params, Map<String,String> headers, AuthParameterPosition position)
clientId
- The client ID to authenticate with.clientSecret
- The client secret to authenticate with.tokenUrl
- The authorization URL for fetching tokens.params
- Additional request parameters.headers
- Additional headers.position
- The position of the authentication parameters in the request.protected abstract Token refresh()
public Token getToken()
getToken
in interface TokenSource
Copyright © 2024. All rights reserved.