MCPcopy Create free account
hub / github.com/EasyIME/PIME / get_authenticated_user

Method get_authenticated_user

python/python3/tornado/auth.py:339–383  ·  view source on GitHub ↗

Gets the OAuth authorized user and access token. This method should be called from the handler for your OAuth callback URL to complete the registration process. We run the callback with the authenticated user dictionary. This dictionary will contain an ``access_key`

(
        self, http_client: Optional[httpclient.AsyncHTTPClient] = None
    )

Source from the content-addressed store, hash-verified

337 self._on_request_token(url, callback_uri, response)
338
339 async def get_authenticated_user(
340 self, http_client: Optional[httpclient.AsyncHTTPClient] = None
341 ) -> Dict[str, Any]:
342 """Gets the OAuth authorized user and access token.
343
344 This method should be called from the handler for your
345 OAuth callback URL to complete the registration process. We run the
346 callback with the authenticated user dictionary. This dictionary
347 will contain an ``access_key`` which can be used to make authorized
348 requests to this service on behalf of the user. The dictionary will
349 also contain other fields such as ``name``, depending on the service
350 used.
351
352 .. versionchanged:: 6.0
353
354 The ``callback`` argument was removed. Use the returned
355 awaitable object instead.
356 """
357 handler = cast(RequestHandler, self)
358 request_key = escape.utf8(handler.get_argument("oauth_token"))
359 oauth_verifier = handler.get_argument("oauth_verifier", None)
360 request_cookie = handler.get_cookie("_oauth_request_token")
361 if not request_cookie:
362 raise AuthError("Missing OAuth request token cookie")
363 handler.clear_cookie("_oauth_request_token")
364 cookie_key, cookie_secret = [
365 base64.b64decode(escape.utf8(i)) for i in request_cookie.split("|")
366 ]
367 if cookie_key != request_key:
368 raise AuthError("Request token does not match cookie")
369 token = dict(
370 key=cookie_key, secret=cookie_secret
371 ) # type: Dict[str, Union[str, bytes]]
372 if oauth_verifier:
373 token["verifier"] = oauth_verifier
374 if http_client is None:
375 http_client = self.get_auth_http_client()
376 assert http_client is not None
377 response = await http_client.fetch(self._oauth_access_token_url(token))
378 access_token = _oauth_parse_response(response.body)
379 user = await self._oauth_get_user_future(access_token)
380 if not user:
381 raise AuthError("Error getting user")
382 user["access_token"] = access_token
383 return user
384
385 def _oauth_request_token_url(
386 self,

Callers 8

getMethod · 0.45
getMethod · 0.45
getMethod · 0.45
getMethod · 0.45
getMethod · 0.45
getMethod · 0.45
getMethod · 0.45
getMethod · 0.45

Calls 10

get_auth_http_clientMethod · 0.95
AuthErrorClass · 0.85
_oauth_parse_responseFunction · 0.85
get_argumentMethod · 0.80
clear_cookieMethod · 0.80
splitMethod · 0.80
get_cookieMethod · 0.45
fetchMethod · 0.45

Tested by 8

getMethod · 0.36
getMethod · 0.36
getMethod · 0.36
getMethod · 0.36
getMethod · 0.36
getMethod · 0.36
getMethod · 0.36
getMethod · 0.36