TokenAuthenticator class

Authenticator that adds a Bearer token to the Authorization header.

Pass an instance to your connector's auth configuration. The apply method will inject Authorization: <prefix> <token> into every request.

class MyConnector extends Connector {
  @override
  Authenticator? get authenticator => TokenAuthenticator('my-token');
}
Implemented types

Constructors

TokenAuthenticator(String token, {String prefix = 'Bearer'})
Creates a TokenAuthenticator with the given token.

Properties

hashCode → int
The hash code for this object.
no setterinherited
prefix → String
The scheme prefix placed before the token value (defaults to 'Bearer').
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
token → String
The raw token value to be included in the Authorization header.
final

Methods

apply(Options options) → void
Adds Authorization: <prefix> <token> 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