HeaderAuthenticator class

Authenticator that injects a single custom header into every request.

Use this when an API requires a proprietary authentication header that is not covered by TokenAuthenticator or BasicAuthenticator, for example X-Api-Key or X-Auth-Token.

class MyConnector extends Connector {
  @override
  Authenticator? get authenticator =>
      HeaderAuthenticator('X-Api-Key', 'my-secret-key');
}
Implemented types

Constructors

HeaderAuthenticator(String headerName, String headerValue)
Creates a HeaderAuthenticator that will set the header headerName to headerValue on every outgoing request.

Properties

hashCode int
The hash code for this object.
no setterinherited
headerName String
The name of the HTTP header to set (e.g. 'X-Api-Key').
final
headerValue String
The value to assign to headerName on every request.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

apply(Options options) → void
Adds the custom header headerName: headerValue to the request options headers.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited