def __detect_os_identity_api_version(self):
        """
        Return preferred OpenStack Identity API version (either one of the two strings ``'2'`` or ``'3'``) or ``None``.

        The following auto-detection strategies are tried (in this order):

        #. Read the environmental variable `OS_IDENTITY_API_VERSION` and check if its value is one of the two strings ``'2'`` or ``'3'``;
        #. Check if a version tag like ``/v3`` or ``/v2.0`` ends the OpenStack auth URL.

        If none of the above worked, return ``None``.

        For more information on ``OS_IDENTITY_API_VERSION``, please see
        `<https://docs.openstack.org/developer/python-openstackclient/authentication.html>`_.
        """
        ver = os.getenv('OS_IDENTITY_API_VERSION', '')
        if ver == '3':
            log.debug(
                "Using OpenStack Identity API v3"
                " because of environmental variable setting `OS_IDENTITY_API_VERSION=3`")
            return '3'
        elif ver == '2' or ver.startswith('2.'):
            log.debug(
                "Using OpenStack Identity API v2"
                " because of environmental variable setting `OS_IDENTITY_API_VERSION=2`")
            return '2'
        elif self._os_auth_url.endswith('/v3'):
            log.debug(
                "Using OpenStack Identity API v3 because of `/v3` ending in auth URL;"
                " set environmental variable OS_IDENTITY_API_VERSION to force use of Identity API v2 instead.")
            return '3'
        elif self._os_auth_url.endswith('/v2.0'):
            log.debug(
                "Using OpenStack Identity API v2 because of `/v2.0` ending in auth URL;"
                " set environmental variable OS_IDENTITY_API_VERSION to force use of Identity API v3 instead.")
            return '2'
        else:
            # auto-detection failed, need to probe
            return None
Return preferred OpenStack Identity API version (either one of the two strings ``'2'`` or ``'3'``) or ``None``.

        The following auto-detection strategies are tried (in this order):

        #. Read the environmental variable `OS_IDENTITY_API_VERSION` and check if its value is one of the two strings ``'2'`` or ``'3'``;
        #. Check if a version tag like ``/v3`` or ``/v2.0`` ends the OpenStack auth URL.

        If none of the above worked, return ``None``.

        For more information on ``OS_IDENTITY_API_VERSION``, please see
        `<https://docs.openstack.org/developer/python-openstackclient/authentication.html>`_.