fix: support custom alg in jwt header for signing (#729)
* fix: support custom alg in jwt header for signing
* lint
diff --git a/google/auth/jwt.py b/google/auth/jwt.py
index a4f04f5..8165dda 100644
--- a/google/auth/jwt.py
+++ b/google/auth/jwt.py
@@ -95,10 +95,11 @@
header.update({"typ": "JWT"})
- if es256 is not None and isinstance(signer, es256.ES256Signer):
- header.update({"alg": "ES256"})
- else:
- header.update({"alg": "RS256"})
+ if "alg" not in header:
+ if es256 is not None and isinstance(signer, es256.ES256Signer):
+ header.update({"alg": "ES256"})
+ else:
+ header.update({"alg": "RS256"})
if key_id is not None:
header["kid"] = key_id