generateMockIdToken method
Implementation
String generateMockIdToken(
{required String projectId,
required String uid,
Map<String, dynamic>? overrides}) {
overrides ??= {};
final certificateObject =
Credentials.applicationDefault() as ServiceAccountCredential;
final claims = {
'aud': projectId,
'exp': clock.now().add(Duration(hours: 1)).millisecondsSinceEpoch ~/ 1000,
'iss': 'https://securetoken.google.com/$projectId',
'sub': uid,
'auth_time': clock.now().millisecondsSinceEpoch ~/ 1000,
...overrides,
};
var builder = JsonWebSignatureBuilder()
..jsonContent = claims
..setProtectedHeader(
'kid', certificateObject.certificate.privateKey.keyId)
..addRecipient(certificateObject.certificate.privateKey,
algorithm: 'RS256');
return builder.build().toCompactSerialization();
}