TokenCredentialCache Class
- java.
lang. Object - com.
microsoft. azure. sdk. iot. service. auth. TokenCredentialCache
- com.
public class TokenCredentialCache
This class generates AAD authentication tokens from a TokenCredential but caches previous tokens when they aren't near expiry.
Field Summary
Modifier and Type | Field and Description |
---|---|
static final java.lang.String | BEARER_TOKEN_PREFIX |
static final java.lang.String[] | IOTHUB_PUBLIC_SCOPE |
Constructor Summary
Constructor | Description |
---|---|
TokenCredentialCache(TokenCredential tokenCredential) |
Construct a new Token |
Method Summary
Modifier and Type | Method and Description |
---|---|
Access |
getAccessToken()
Get a valid AAD authentication token. |
Token |
getTokenCredential() |
java.lang.String |
getTokenString()
Get the access token string, including the Bearer prefix. |
Methods inherited from java.lang.Object
Field Details
BEARER_TOKEN_PREFIX
public static final String BEARER_TOKEN_PREFIX
IOTHUB_PUBLIC_SCOPE
public static final String[] IOTHUB_PUBLIC_SCOPE
Constructor Details
TokenCredentialCache
public TokenCredentialCache(TokenCredential tokenCredential)
Construct a new TokenCredentialCache instance.
Parameters:
Method Details
getAccessToken
public AccessToken getAccessToken()
Get a valid AAD authentication token. This may be the same as a previously returned token if it is not near expiration time yet. If a token is less than or equal to 9 minutes away from expiring or is expired already, the token will be renewed. Otherwise, a cached token will be returned.
Returns:
getTokenCredential
public TokenCredential getTokenCredential()
Returns:
getTokenString
public String getTokenString()
Get the access token string, including the Bearer prefix.
Returns:
Applies to
Azure SDK for Java