Skip to content

Commit 85d96e3

Browse files
authored
fix python example in generating-a-json-web-token-jwt-for-a-github-app.md
1 parent b63a1fc commit 85d96e3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

content/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ puts jwt
8383
import sys
8484
import time
8585

86-
import jwt
86+
from jwt import JWT, jwk_from_pem
8787

8888

8989
# Get PEM file path
@@ -101,7 +101,7 @@ else:
101101

102102
# Open PEM
103103
with open(pem, 'rb') as pem_file:
104-
signing_key = pem_file.read()
104+
signing_key = jwk_from_pem(pem_file.read())
105105

106106
payload = {
107107
# Issued at time
@@ -115,7 +115,8 @@ payload = {
115115
}
116116

117117
# Create JWT
118-
encoded_jwt = jwt.encode(payload, signing_key, algorithm='RS256')
118+
instance = JWT()
119+
encoded_jwt = instance.encode(payload, signing_key, alg='RS256')
119120

120121
print(f"JWT: {encoded_jwt}")
121122
```

0 commit comments

Comments
 (0)