public function callback($input)
    {
        if (isset($input['error'])) {
            throw new AuthenticationException($input['error'].':'.$input['error_description']);
        }

        if (!isset($input['code']) || empty($input['code'])) {
            throw new AuthenticationException('invalid code');
        }

        if (!isset($input['state']) || empty($input['state'])) {
            throw new AuthenticationException('invalid state');
        }

        if (!$this->store->has($input['state'])) {
            throw new AuthenticationException('state expired');
        }

        $access_token = $this->requestAccessToken($input['code']);

        return $this->requestProfile($access_token);
    }