Skip to content

Commit ab017e6

Browse files
committed
jwt dev dep
1 parent dd2d39a commit ab017e6

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

fasthtml/oauth.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .common import *
1111
from oauthlib.oauth2 import WebApplicationClient
1212
from urllib.parse import urlparse, urlencode, parse_qs, quote, unquote
13-
import secrets, httpx, time, jwt
13+
import secrets, httpx, time
1414

1515
# %% ../nbs/api/08_oauth.ipynb
1616
class _AppClient(WebApplicationClient):
@@ -125,6 +125,7 @@ def __init__(self, client_id, key_id, team_id, private_key, code=None, scope=Non
125125

126126
@property
127127
def client_secret(self):
128+
import jwt
128129
now = int(time.time())
129130
payload = dict(iss=self.team_id, iat=now, exp=now + 86400 * 180, aud='https://appleid.apple.com', sub=self.client_id)
130131
return jwt.encode(payload, self.private_key, algorithm='ES256', headers={'kid': self.key_id})
@@ -134,6 +135,7 @@ def client_secret(self, value): pass
134135

135136
def get_info(self, token=None):
136137
"Decode user info from the ID token"
138+
import jwt
137139
if token: self.token = token
138140
return jwt.decode(self.token.get('id_token'), options={"verify_signature": False})
139141

nbs/api/08_oauth.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"from fasthtml.common import *\n",
4242
"from oauthlib.oauth2 import WebApplicationClient\n",
4343
"from urllib.parse import urlparse, urlencode, parse_qs, quote, unquote\n",
44-
"import secrets, httpx, time, jwt"
44+
"import secrets, httpx, time"
4545
]
4646
},
4747
{
@@ -263,6 +263,7 @@
263263
" \n",
264264
" @property\n",
265265
" def client_secret(self):\n",
266+
" import jwt\n",
266267
" now = int(time.time())\n",
267268
" payload = dict(iss=self.team_id, iat=now, exp=now + 86400 * 180, aud='https://appleid.apple.com', sub=self.client_id)\n",
268269
" return jwt.encode(payload, self.private_key, algorithm='ES256', headers={'kid': self.key_id})\n",
@@ -272,6 +273,7 @@
272273
" \n",
273274
" def get_info(self, token=None):\n",
274275
" \"Decode user info from the ID token\"\n",
276+
" import jwt\n",
275277
" if token: self.token = token\n",
276278
" return jwt.decode(self.token.get('id_token'), options={\"verify_signature\": False})"
277279
]

settings.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ lib_name = python-fasthtml
44
version = 0.12.37
55
min_python = 3.10
66
license = apache2
7-
requirements = fastcore>=1.8.1 python-dateutil starlette>0.33 oauthlib itsdangerous uvicorn[standard]>=0.30 httpx fastlite>=0.1.1 python-multipart beautifulsoup4 PyJWT
8-
dev_requirements = ipython lxml pysymbol_llm monsterui
7+
requirements = fastcore>=1.8.1 python-dateutil starlette>0.33 oauthlib itsdangerous uvicorn[standard]>=0.30 httpx fastlite>=0.1.1 python-multipart beautifulsoup4
8+
dev_requirements = ipython lxml pysymbol_llm monsterui PyJWT
99
black_formatting = False
1010
conda_user = fastai
1111
doc_path = _docs

0 commit comments

Comments
 (0)