Credential class

Token is a structure for storing authentication credentials for third-party pub registries. A token holds registry url, credential kind and token itself.

Token could be serialized into and from JSON format structured like this:

{
  "url": "https://example.com/",
  "token": "gjrjo7Tm2F0u64cTsECDq4jBNZYhco"
}

Constructors

Credential.env(Uri url, String? env)
Create credential that stores environment variable name that stores token value.
Credential.fromJson(Map<String, dynamic> json)
Deserialize json into Credential type.
factory
Credential.token(Uri url, String? token)
Create credential that stores clear text token.

Properties

env String?
Environment variable name that stores token value
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
token String?
Authentication token value
final
unknownFields Map<String, dynamic>
Unknown fields found in pub-tokens.json. The fields might be created by the future version of pub tool. We don't want to override them when using the old SDK.
final
url Uri
Server url which this token authenticates.
final

Methods

canAuthenticate(String url) bool
Returns whether or not given url could be authenticated using this credential.
getAuthorizationHeaderValue() Future<String>
Returns future that resolves "Authorization" header value used for authenticating.
isValid() bool
Returns boolean indicates whether or not the credentials is valid.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Serializes Credential into json format.
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

isValidBearerToken(String candidate) bool
Whether candidate can be used as a bearer token.