@PublicApi
public interface TokenHandler
| Modifier and Type | Interface and Description |
|---|---|
static interface |
TokenHandler.ClientTokenCallback<T>
Callback to execute with a
ClientToken. |
static class |
TokenHandler.InvalidTokenException
Indicates that there was a problem with a
ClientToken and it couldn't be used for successful
authorisation with an OAuth 2.0 resource server. |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
execute(String clientTokenId,
TokenHandler.ClientTokenCallback<T> callback)
Handles the use of
ClientToken, automatically applying a refresh before executing the callback if
required. |
<T> T |
execute(String clientTokenId,
TokenHandler.ClientTokenCallback<T> callback,
Duration margin)
Handles the use of
ClientToken, automatically applying a refresh before executing the callback if
required. |
ClientToken |
getRefreshedToken(String clientTokenId)
Refreshes and returns the client token, saving the up to date token to the store.
|
ClientToken |
getRefreshedToken(String clientTokenId,
Duration margin)
Refreshes if access token is already expired or expires within the margin period.
|
<T> T execute(String clientTokenId, TokenHandler.ClientTokenCallback<T> callback) throws UnrecoverableTokenException, RecoverableTokenException
ClientToken, automatically applying a refresh before executing the callback if
required.
This method may update the ClientTokenMetadata of the token.
Note that the TokenHandler.ClientTokenCallback may be executed more than once if it throws
TokenHandler.InvalidTokenException.
T - the result type.clientTokenId - the id of the token to be used in the execution, or to be refreshed if requiredcallback - the callback to be executed.UnrecoverableTokenException - thrown if the token is invalid and can't be automatically refreshedRecoverableTokenException - thrown if the token is invalid but it might be possible to recover<T> T execute(String clientTokenId, TokenHandler.ClientTokenCallback<T> callback, Duration margin) throws UnrecoverableTokenException, RecoverableTokenException
ClientToken, automatically applying a refresh before executing the callback if
required.
This method may update the ClientTokenMetadata of the token.
Note that the TokenHandler.ClientTokenCallback may be executed more than once if it throws
TokenHandler.InvalidTokenException.
T - the result type.clientTokenId - the id of the token to be used in the execution, or to be refreshed if requiredcallback - the callback to be executed.margin - only refreshes token if expiry is before now + marginUnrecoverableTokenException - thrown if the token is invalid and can't be automatically refreshedRecoverableTokenException - thrown if the token is invalid but it might be possible to recoverClientToken getRefreshedToken(String clientTokenId) throws UnrecoverableTokenException, RecoverableTokenException
ClientTokenMetadata of the token.clientTokenId - the id of the token to be refreshedUnrecoverableTokenException - thrown if the token is invalid and can't be automatically refreshedRecoverableTokenException - thrown if the token is invalid but it might be possible to recoverClientToken getRefreshedToken(String clientTokenId, Duration margin) throws UnrecoverableTokenException, RecoverableTokenException
margin then the refreshed token is returned. It means
that in such case returned token will be valid only for part of the margin period.
May update ClientTokenMetadata of the token.clientTokenId - the id of the token to be refreshed if requiredmargin - only refreshes token if expiry is before now + marginUnrecoverableTokenException - thrown if the token is invalid and can't be automatically refreshedRecoverableTokenException - thrown if the token is invalid but it might be possible to recoverCopyright © 2020 Atlassian. All rights reserved.