示例#1
0
    async def _async_create_session(self, code):
        """Create point session and entries."""
        from pypoint import PointSession
        flow = self.hass.data[DATA_FLOW_IMPL][DOMAIN]
        client_id = flow[CLIENT_ID]
        client_secret = flow[CLIENT_SECRET]
        point_session = PointSession(
            client_id,
            client_secret=client_secret,
        )
        token = await self.hass.async_add_executor_job(
            point_session.get_access_token, code)
        _LOGGER.debug("Got new token")
        if not point_session.is_authorized:
            _LOGGER.error('Authentication Error')
            return self.async_abort(reason='auth_error')

        _LOGGER.info('Successfully authenticated Point')
        user_email = point_session.user().get('email') or ""

        return self.async_create_entry(
            title=user_email,
            data={
                'token': token,
                'refresh_args': {
                    'client_id': client_id,
                    'client_secret': client_secret
                }
            },
        )
示例#2
0
    async def _async_create_session(self, code):
        """Create point session and entries."""
        from pypoint import PointSession
        flow = self.hass.data[DATA_FLOW_IMPL][DOMAIN]
        client_id = flow[CLIENT_ID]
        client_secret = flow[CLIENT_SECRET]
        point_session = PointSession(
            client_id,
            client_secret=client_secret,
        )
        token = await self.hass.async_add_executor_job(
            point_session.get_access_token, code)
        _LOGGER.debug("Got new token")
        if not point_session.is_authorized:
            _LOGGER.error('Authentication Error')
            return self.async_abort(reason='auth_error')

        _LOGGER.info('Successfully authenticated Point')
        user_email = point_session.user().get('email') or ""

        return self.async_create_entry(
            title=user_email,
            data={
                'token': token,
                'refresh_args': {
                    'client_id': client_id,
                    'client_secret': client_secret
                }
            },
        )
示例#3
0
    async def _async_create_session(self, code):
        """Create point session and entries."""

        flow = self.hass.data[DATA_FLOW_IMPL][DOMAIN]
        client_id = flow[CLIENT_ID]
        client_secret = flow[CLIENT_SECRET]
        point_session = PointSession(client_id, client_secret=client_secret)
        token = await self.hass.async_add_executor_job(
            point_session.get_access_token, code)
        _LOGGER.debug("Got new token")
        if not point_session.is_authorized:
            _LOGGER.error("Authentication Error")
            return self.async_abort(reason="auth_error")

        _LOGGER.info("Successfully authenticated Point")
        user_email = point_session.user().get("email") or ""

        return self.async_create_entry(
            title=user_email,
            data={
                "token": token,
                "refresh_args": {
                    "client_id": client_id,
                    "client_secret": client_secret,
                },
            },
        )