parseJwtHeader static method

Map<String, dynamic> parseJwtHeader(
  1. String token
)

This method it's used to get a payload data by a firebase jwt token

Implementation

static Map<String, dynamic> parseJwtHeader(String token) {
  final parts = token.split('.');
  if (parts.length != 3) {
    throw Exception('invalid token');
  }

  final payload = _decodeBase64(parts[0]);
  final payloadMap = json.decode(payload);
  if (payloadMap is! Map<String, dynamic>) {
    throw Exception('invalid payload');
  }

  return payloadMap;
}