Skip to content

Commit ffa6628

Browse files
chore: Improve exception message in case of missing JWT dependencies (box/box-codegen#703) (#542)
1 parent d281d35 commit ffa6628

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "4148197", "specHash": "c303afc", "version": "1.13.0" }
1+
{ "engineHash": "e5d612a", "specHash": "c303afc", "version": "1.13.0" }

box_sdk_gen/internal/utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,10 @@ def get_rsa_private_key(
330330
private_key: str,
331331
passphrase: str,
332332
) -> Any:
333+
if default_backend is None or serialization is None:
334+
raise ImportError(
335+
'Missing `cryptography` dependency. `cryptography` library is required to create JWT assertion.'
336+
)
333337
encoded_private_key = encode_str_ascii_or_raise(private_key)
334338
encoded_passphrase = encode_str_ascii_or_raise(passphrase)
335339

@@ -341,6 +345,10 @@ def get_rsa_private_key(
341345

342346

343347
def create_jwt_assertion(claims: dict, key: JwtKey, options: JwtSignOptions) -> str:
348+
if jwt is None:
349+
raise ImportError(
350+
'Missing `PyJWT` dependency. `PyJWT` library is required to create JWT assertion.'
351+
)
344352
return jwt.encode(
345353
{
346354
'iss': options.issuer,

0 commit comments

Comments
 (0)