Class ApiKeyAuthenticationProvider

java.lang.Object
com.microsoft.kiota.authentication.ApiKeyAuthenticationProvider
All Implemented Interfaces:
AuthenticationProvider

public class ApiKeyAuthenticationProvider extends Object implements AuthenticationProvider
This authentication provider adds an API key to the request as a query parameter or header.
  • Constructor Details

    • ApiKeyAuthenticationProvider

      public ApiKeyAuthenticationProvider(@Nonnull String apiKey, @Nonnull String paramName, @Nonnull ApiKeyLocation location, @Nonnull String... validHosts)
      Creates a new instance of ApiKeyAuthenticationProvider.
      Parameters:
      apiKey - The API key to use.
      paramName - The name of the query parameter or header to use.
      location - The location of the API key.
      validHosts - The list of allowed hosts for which to add the API key.
  • Method Details

    • authenticateRequest

      public void authenticateRequest(@Nonnull RequestInformation request, @Nullable Map<String,Object> additionalAuthenticationContext)
      Authenticates the application request.
      Specified by:
      authenticateRequest in interface AuthenticationProvider
      Parameters:
      request - the request to authenticate.
      additionalAuthenticationContext - Additional authentication context to pass to the authentication library.