def check_third_party_caveat(self, ctx, info): InfoStorage.info = info raise InteractionRequiredError( httpbakery.Error( code=httpbakery.ERR_INTERACTION_REQUIRED, version=httpbakery.request_version( request.headers), message='interaction required', info=httpbakery.ErrorInfo( wait_url='http://0.3.2.1/wait?' 'dischargeid=1', visit_url='http://0.3.2.1/visit?' 'dischargeid=1'), ), )
async def _connect_with_login(self, endpoints): """Connect to the websocket. If uuid is None, the connection will be to the controller. Otherwise it will be to the model. :return: The response field of login response JSON object. """ success = False try: await self._connect(endpoints) # It's possible that we may get several discharge-required errors, # corresponding to different levels of authentication, so retry # a few times. for i in range(0, 2): result = (await self.login())['response'] macaroonJSON = result.get('discharge-required') if macaroonJSON is None: self.info = result success = True return result macaroon = bakery.Macaroon.from_dict(macaroonJSON) self.bakery_client.handle_error( httpbakery.Error( code=httpbakery.ERR_DISCHARGE_REQUIRED, message=result.get('discharge-required-error'), version=macaroon.version, info=httpbakery.ErrorInfo( macaroon=macaroon, macaroon_path=result.get('macaroon-path'), ), ), # note: remove the port number. 'https://' + self.endpoint + '/', ) raise errors.JujuAuthError('failed to authenticate ' 'after several attempts') finally: if not success: await self.close() else: self._pinger_task.start()