authenticateAnonymously method

Future<UserInfo> authenticateAnonymously({
  1. String? resource,
  2. List<String>? scopes,
})

Implementation

Future<UserInfo> authenticateAnonymously({
  /// Resource indicator (RFC 8707). See [authenticate]. Defaults to the `resource` given to [configure].
  String? resource,

  /// Scopes to request. See [authenticate]. Defaults to the `scopes` given to [configure].
  List<String>? scopes,
}) async {
  final kid = await _storage.getAnonymousKeyID(name);
  AnonymousRequest makeRequest(String jwt) {
    return AnonymousRequest(
      clientID: clientID,
      jwt: jwt,
      scope: getAnonymousScopes(scopes ?? _defaultScopes),
      resource: resource ?? _defaultResource,
    );
  }

  if (kid == null) {
    return _authenticateAnonymouslyCreate(makeRequest);
  }
  return _authenticateAnonymouslyExisting(kid, makeRequest);
}