def _set_bearer_user_vars(allowed_client_ids, scopes):
all_scopes, sufficient_scopes = _process_scopes(scopes)<EOL>try:<EOL><INDENT>authorized_scopes = oauth.get_authorized_scopes(sorted(all_scopes))<EOL><DEDENT>except oauth.Error:<EOL><INDENT>_logger.debug('<STR_LIT>', exc_info=True)<EOL>return<EOL><DEDENT>if not _are_scopes_sufficient(authorized_scopes, sufficient_scopes):<EOL><INDENT>_logger.warning('<STR_LIT>')<EOL>return<EOL><DEDENT>client_id = oauth.get_client_id(authorized_scopes)<EOL>if (list(allowed_client_ids) != SKIP_CLIENT_ID_CHECK and<EOL>client_id not in allowed_client_ids):<EOL><INDENT>_logger.warning('<STR_LIT>', client_id)<EOL>return<EOL><DEDENT>os.environ[_ENV_USE_OAUTH_SCOPE] = '<STR_LIT:U+0020>'.join(authorized_scopes)<EOL>_logger.debug('<STR_LIT>')<EOL>
Validate the oauth bearer token and set endpoints auth user variables.

    If the bearer token is valid, this sets ENDPOINTS_USE_OAUTH_SCOPE.  This
    provides enough information that our endpoints.get_current_user() function
    can get the user.

    Args:
      allowed_client_ids: List of client IDs that are acceptable.
      scopes: List of acceptable scopes.