File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515app_urlpatterns = [
1616 re_path (r'^' , include (router .urls )),
1717 re_path (r'auth/login/?$' , views .AuthLoginView .as_view ({"post" : "login" })),
18+ re_path (r'auth/token/?$' , views .AuthTokenView .as_view ({"post" : "token" })),
1819 re_path (r'auth/token/(?P<key>[-_\w]+)/?$' , views .AuthTokenView .as_view ({"get" : "token" })),
1920 # limits
2021 re_path (
Original file line number Diff line number Diff line change @@ -144,8 +144,14 @@ class AuthTokenView(GenericViewSet):
144144 permission_classes = (AllowAny , )
145145
146146 def token (self , request , * args , ** kwargs ):
147- oauth = oauth_cache_manager .get_token (self .kwargs ['key' ])
148- if oauth :
147+ if 'key' in self .kwargs :
148+ oauth = oauth_cache_manager .get_token (self .kwargs ['key' ])
149+ else :
150+ try :
151+ oauth = json .loads (request .body .decode ("utf8" ))
152+ except json .decoder .JSONDecodeError :
153+ return HttpResponse (status = 400 )
154+ if oauth and 'access_token' in oauth :
149155 user = oauth_cache_manager .get_user (oauth ['access_token' ])
150156 alias = request .query_params .get ('alias' , '' )
151157 token = models .base .Token (owner = user , alias = alias , oauth = oauth )
You can’t perform that action at this time.
0 commit comments