Interface ITokenProvider


public interface ITokenProvider
An interface that provides a process of getting access tokens for API.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
    The Token recieved form Microsoft Cognitive service authentication endpoint with Time-to-live vale (TTL).
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Generates a new token.
    Returns an active (non-expired) token text that was generated by #generateToken() method.
    Returns a token that was generated by #generateToken() method.
  • Method Details

    • generateToken

      void generateToken(String key)
      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 be null
      Throws:
      InvalidAccessKeyException - if access key is invalid for Microsoft Translator serivce
      ExceededQuotaException - if service of Microsoft Translator quota is exeeded
      TranslationServiceException - if illegal arguments or some other error in this Language Tool service
      ServiceUnavailableException - if serivce is unavailable
    • getToken

      Returns a token that was generated by #generateToken() method.
      Returns:
      a generated token, never returns null
    • getActiveTokenText

      String getActiveTokenText(String key)
      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