fromIdToken static method

Future<OidcUser> fromIdToken({
  1. required OidcToken token,
  2. bool strictVerification = false,
  3. JsonWebKeyStore? keystore,
  4. OidcStore? cacheStore,
  5. List<String>? allowedAlgorithms,
  6. Map<String, dynamic>? attributes,
  7. Map<String, dynamic>? userInfo,
  8. String? idTokenOverride,
})

Creates a OidcUser from an encoded id_token passed via token.

You can verify the idToken by passing the keystore parameter.

You can also pass optional attributes that will get stored with the user.

Implementation

static Future<OidcUser> fromIdToken({
  required OidcToken token,
  bool strictVerification = false,
  JsonWebKeyStore? keystore,
  OidcStore? cacheStore,
  List<String>? allowedAlgorithms,
  Map<String, dynamic>? attributes,
  Map<String, dynamic>? userInfo,
  String? idTokenOverride,
}) async {
  final idToken = idTokenOverride ?? token.idToken;
  if (idToken == null) {
    throw const OidcException(
      "Server didn't return the id_token.",
    );
  }
  final webToken = await _getWebToken(
    keystore,
    idToken,
    allowedAlgorithms,
    cacheStore,
    strictVerification,
  );

  return OidcUser._(
    idToken: idToken,
    parsedIdToken: webToken,
    token: token,
    attributes: attributes ?? const {},
    allowedAlgorithms: allowedAlgorithms,
    keystore: keystore,
    userInfo: userInfo ?? const {},
  );
}