code: def _get_token(
      request=None, allowed_auth_schemes=('OAuth', 'Bearer'),
      allowed_query_keys=('bearer_token', 'access_token')):
    allowed_auth_schemes = _listlike_guard(
        allowed_auth_schemes, 'allowed_auth_schemes', iterable_only=True)
    auth_header = os.environ.get('HTTP_AUTHORIZATION')
    if auth_header:
      for auth_scheme in allowed_auth_schemes:
        if auth_header.startswith(auth_scheme):
          return auth_header[len(auth_scheme) + 1:]
      return None
    if request:
      allowed_query_keys = _listlike_guard(
          allowed_query_keys, 'allowed_query_keys', iterable_only=True)
      for key in allowed_query_keys:
        token, _ = request.get_unrecognized_field_info(key)
        if token:
          return token