@@ -87,7 +87,7 @@ class OpenIdMixin(object):
87
87
88
88
def authenticate_redirect (
89
89
self ,
90
- callback_uri : str = None ,
90
+ callback_uri : Optional [ str ] = None ,
91
91
ax_attrs : List [str ] = ["name" , "email" , "language" , "username" ],
92
92
) -> None :
93
93
"""Redirects to the authentication URL for this service.
@@ -114,7 +114,7 @@ def authenticate_redirect(
114
114
handler .redirect (endpoint + "?" + urllib .parse .urlencode (args ))
115
115
116
116
async def get_authenticated_user (
117
- self , http_client : httpclient .AsyncHTTPClient = None
117
+ self , http_client : Optional [ httpclient .AsyncHTTPClient ] = None
118
118
) -> Dict [str , Any ]:
119
119
"""Fetches the authenticated user data upon redirect.
120
120
@@ -146,7 +146,10 @@ async def get_authenticated_user(
146
146
return self ._on_authentication_verified (resp )
147
147
148
148
def _openid_args (
149
- self , callback_uri : str , ax_attrs : Iterable [str ] = [], oauth_scope : str = None
149
+ self ,
150
+ callback_uri : str ,
151
+ ax_attrs : Iterable [str ] = [],
152
+ oauth_scope : Optional [str ] = None ,
150
153
) -> Dict [str , str ]:
151
154
handler = cast (RequestHandler , self )
152
155
url = urllib .parse .urljoin (handler .request .full_url (), callback_uri )
@@ -286,9 +289,9 @@ class OAuthMixin(object):
286
289
287
290
async def authorize_redirect (
288
291
self ,
289
- callback_uri : str = None ,
290
- extra_params : Dict [str , Any ] = None ,
291
- http_client : httpclient .AsyncHTTPClient = None ,
292
+ callback_uri : Optional [ str ] = None ,
293
+ extra_params : Optional [ Dict [str , Any ] ] = None ,
294
+ http_client : Optional [ httpclient .AsyncHTTPClient ] = None ,
292
295
) -> None :
293
296
"""Redirects the user to obtain OAuth authorization for this service.
294
297
@@ -334,7 +337,7 @@ async def authorize_redirect(
334
337
self ._on_request_token (url , callback_uri , response )
335
338
336
339
async def get_authenticated_user (
337
- self , http_client : httpclient .AsyncHTTPClient = None
340
+ self , http_client : Optional [ httpclient .AsyncHTTPClient ] = None
338
341
) -> Dict [str , Any ]:
339
342
"""Gets the OAuth authorized user and access token.
340
343
@@ -380,7 +383,9 @@ async def get_authenticated_user(
380
383
return user
381
384
382
385
def _oauth_request_token_url (
383
- self , callback_uri : str = None , extra_params : Dict [str , Any ] = None
386
+ self ,
387
+ callback_uri : Optional [str ] = None ,
388
+ extra_params : Optional [Dict [str , Any ]] = None ,
384
389
) -> str :
385
390
handler = cast (RequestHandler , self )
386
391
consumer_token = self ._oauth_consumer_token ()
@@ -547,11 +552,11 @@ class OAuth2Mixin(object):
547
552
548
553
def authorize_redirect (
549
554
self ,
550
- redirect_uri : str = None ,
551
- client_id : str = None ,
552
- client_secret : str = None ,
553
- extra_params : Dict [str , Any ] = None ,
554
- scope : str = None ,
555
+ redirect_uri : Optional [ str ] = None ,
556
+ client_id : Optional [ str ] = None ,
557
+ client_secret : Optional [ str ] = None ,
558
+ extra_params : Optional [ Dict [str , Any ] ] = None ,
559
+ scope : Optional [ str ] = None ,
555
560
response_type : str = "code" ,
556
561
) -> None :
557
562
"""Redirects the user to obtain OAuth authorization for this service.
@@ -582,11 +587,11 @@ def authorize_redirect(
582
587
583
588
def _oauth_request_token_url (
584
589
self ,
585
- redirect_uri : str = None ,
586
- client_id : str = None ,
587
- client_secret : str = None ,
588
- code : str = None ,
589
- extra_params : Dict [str , Any ] = None ,
590
+ redirect_uri : Optional [ str ] = None ,
591
+ client_id : Optional [ str ] = None ,
592
+ client_secret : Optional [ str ] = None ,
593
+ code : Optional [ str ] = None ,
594
+ extra_params : Optional [ Dict [str , Any ] ] = None ,
590
595
) -> str :
591
596
url = self ._OAUTH_ACCESS_TOKEN_URL # type: ignore
592
597
args = {} # type: Dict[str, str]
@@ -605,8 +610,8 @@ def _oauth_request_token_url(
605
610
async def oauth2_request (
606
611
self ,
607
612
url : str ,
608
- access_token : str = None ,
609
- post_args : Dict [str , Any ] = None ,
613
+ access_token : Optional [ str ] = None ,
614
+ post_args : Optional [ Dict [str , Any ] ] = None ,
610
615
** args : Any
611
616
) -> Any :
612
617
"""Fetches the given URL auth an OAuth2 access token.
@@ -709,7 +714,7 @@ async def get(self):
709
714
_OAUTH_NO_CALLBACKS = False
710
715
_TWITTER_BASE_URL = "https://api.twitter.com/1.1"
711
716
712
- async def authenticate_redirect (self , callback_uri : str = None ) -> None :
717
+ async def authenticate_redirect (self , callback_uri : Optional [ str ] = None ) -> None :
713
718
"""Just like `~OAuthMixin.authorize_redirect`, but
714
719
auto-redirects if authorized.
715
720
@@ -735,7 +740,7 @@ async def twitter_request(
735
740
self ,
736
741
path : str ,
737
742
access_token : Dict [str , Any ],
738
- post_args : Dict [str , Any ] = None ,
743
+ post_args : Optional [ Dict [str , Any ] ] = None ,
739
744
** args : Any
740
745
) -> Any :
741
746
"""Fetches the given API path, e.g., ``statuses/user_timeline/btaylor``
@@ -930,7 +935,7 @@ async def get_authenticated_user(
930
935
client_id : str ,
931
936
client_secret : str ,
932
937
code : str ,
933
- extra_fields : Dict [str , Any ] = None ,
938
+ extra_fields : Optional [ Dict [str , Any ] ] = None ,
934
939
) -> Optional [Dict [str , Any ]]:
935
940
"""Handles the login for the Facebook user, returning a user object.
936
941
@@ -1034,8 +1039,8 @@ async def get(self):
1034
1039
async def facebook_request (
1035
1040
self ,
1036
1041
path : str ,
1037
- access_token : str = None ,
1038
- post_args : Dict [str , Any ] = None ,
1042
+ access_token : Optional [ str ] = None ,
1043
+ post_args : Optional [ Dict [str , Any ] ] = None ,
1039
1044
** args : Any
1040
1045
) -> Any :
1041
1046
"""Fetches the given relative API path, e.g., "/btaylor/picture"
@@ -1099,7 +1104,7 @@ def _oauth_signature(
1099
1104
method : str ,
1100
1105
url : str ,
1101
1106
parameters : Dict [str , Any ] = {},
1102
- token : Dict [str , Any ] = None ,
1107
+ token : Optional [ Dict [str , Any ] ] = None ,
1103
1108
) -> bytes :
1104
1109
"""Calculates the HMAC-SHA1 OAuth signature for the given request.
1105
1110
@@ -1132,7 +1137,7 @@ def _oauth10a_signature(
1132
1137
method : str ,
1133
1138
url : str ,
1134
1139
parameters : Dict [str , Any ] = {},
1135
- token : Dict [str , Any ] = None ,
1140
+ token : Optional [ Dict [str , Any ] ] = None ,
1136
1141
) -> bytes :
1137
1142
"""Calculates the HMAC-SHA1 OAuth 1.0a signature for the given request.
1138
1143
0 commit comments