/** * @param string $code * @throws InvalidDataException | BadAuthenticationException | InstagramException * @return bool */ public function authenticate($code) { if (!$this->codeValidator->isValid($code)) { throw new InvalidCodeException('Invalid code param'); } $data = $this->instagramWrapper->getOAuthToken($code); if (!empty($data->error_message)) { throw new BadAuthenticationException('Could not connect to the Instagram'); } $this->sessionContainer->data = $data; }