Package com.e1c.langtool.microsoft
Interface ITokenProvider
public interface ITokenProvider
An interface that provides a process of getting access tokens for API.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classThe Token recieved form Microsoft Cognitive service authentication endpoint with Time-to-live vale (TTL). -
Method Summary
Modifier and TypeMethodDescriptionvoidgenerateToken(String key) Generates a new token.getActiveTokenText(String key) Returns an active (non-expired) token text that was generated by#generateToken()method.getToken()Returns a token that was generated by#generateToken()method.
-
Method Details
-
generateToken
Generates a new token.WARNING: this method makes the old token was generated before for the given key as invalid.
- Parameters:
key- a key that used for generating a token, cannot benull- Throws:
InvalidAccessKeyException- if access key is invalid for Microsoft Translator serivceExceededQuotaException- if service of Microsoft Translator quota is exeededTranslationServiceException- if illegal arguments or some other error in this Language Tool serviceServiceUnavailableException- if serivce is unavailable
-
getToken
ITokenProvider.Token getToken()Returns a token that was generated by#generateToken()method.- Returns:
- a generated token, never returns
null
-
getActiveTokenText
Returns an active (non-expired) token text that was generated by#generateToken()method. Implementer must re-update token if TTL (time to live) is expired.- Returns:
- a generated token, cannot be
null
-