/** * {@inheritdoc} */ public function interact(InputInterface $input, OutputInterface $output) { $oAuthToken = null; $client = new Client(); $authenticationAttempts = 0; $authentication = ['username' => null, 'password' => null, 'base_url' => $this->apiUrl, 'repo_domain_url' => $this->repoUrl]; while (null === $oAuthToken) { if ($authenticationAttempts > 0) { $this->styleHelper->error('Authentication failed please try again.'); } $authentication['base_url'] = $this->styleHelper->ask(sprintf('%s API url', $this->label), $authentication['base_url'], [$this, 'validateUrl']); $authentication['repo_domain_url'] = $this->styleHelper->ask(sprintf('%s web url', $this->label), $authentication['repo_domain_url'], [$this, 'validateUrl']); $this->styleHelper->note(['For security reasons an authentication token will be stored instead of your password.', sprintf('To revoke access of this token you can visit %s/settings/tokens', $authentication['repo_domain_url'])]); $authentication['username'] = $this->styleHelper->ask('Username', $authentication['username'], [$this, 'validateNoneEmpty']); $authentication['password'] = $this->styleHelper->askHidden('Password', [$this, 'validateNoneEmpty']); try { $client->authenticate($authentication['username'], $authentication['password']); $oAuthToken = $this->createAuthorization($client)['token']; } catch (TwoFactorAuthenticationRequiredException $e) { $oAuthToken = $this->handle2fa($client, $e)['token']; } } return $this->getConfigStructure($authentication['username'], $oAuthToken, $authentication['base_url'], $authentication['repo_domain_url']); }