code: def oauth_get_user(client_id, account_info=None, access_token=None):
      
      if access_token:
          token = RemoteToken.get_by_token(client_id, access_token)
          if token:
              return token.remote_account.user
  
      if account_info:
          external_id = _get_external_id(account_info)
          if external_id:
              user_identity = UserIdentity.query.filter_by(
                  id=external_id['id'], method=external_id['method']).first()
              if user_identity:
                  return user_identity.user
          email = account_info.get('user', {}).get('email')
          if email:
              return User.query.filter_by(email=email).one_or_none()
      return None
docs: Retrieve user object for the given request.
  
      Uses either the access token or extracted account information to retrieve
      the user object.
  
      :param client_id: The client id.
      :param account_info: The dictionary with the account info.
          (Default: ``None``)
      :param access_token: The access token. (Default: ``None``)
      :returns: A :class:`invenio_accounts.models.User` instance or ``None``.