Ejemplo n.º 1
0
void HyvesAPI::handleResult(int requestId, ResultDocument result, bool errorOccurred) {
	
	m_d->log->debug(QString("Received response for request #%1").arg(requestId));
	
	if (errorOccurred || result.errorCode() != ResultDocument::RESULT_OK) {
		m_d->log->error(QString("An error occurred during API call (request #%3): %1 %2").arg(result.errorCode()).arg(result.errorMessage()).arg(requestId));
		emit error(result);
		emit error(requestId, result);
		return;
	}
	
	if (m_d->accessToken == 0) {
		GenusApis::OAuthAccessToken *accessToken = result.toAccessToken("auth_accesstokenByDesktoptoken_result");
		
		if (accessToken != 0) {
			m_d->log->notice("Got access token from API");
			
			m_d->accessToken = accessToken;
			
			m_d->loginStatus = HyvesAPI::LoggedIn;
			emit accessTokenReady();
			return;
		}

		m_d->log->debug("Response received but no access token yet!");
	}
	
	emit resultReady(result);
	emit resultReady(requestId, result);
}
Ejemplo n.º 2
0
AppLogic::AppLogic()
{
    login = new QtGoogleOAuthLogin(this);
    login->setClientId(QStringLiteral("***********.apps.googleusercontent.com"));
    login->setClientSecret(QStringLiteral("********************"));
    login->setScope(QStringLiteral("http://picasaweb.google.com/data/"));

    QSettings settings;
    login->setRefreshToken(settings.value("refreshToken").toString());
    // Comment out refresh token to start login from scratch

    connect(login, SIGNAL(displayLoginPage(QUrl)), SLOT(displayLoginPage(QUrl)));
    connect(login, SIGNAL(accessTokenReady(QString)), SLOT(accessTokenReady(QString)));
    connect(login, SIGNAL(refreshTokenReady(QString)), SLOT(refreshTokenReady(QString)));
    connect(login, SIGNAL(error(QString)), SLOT(error(QString)));

    window = new QWidget();
}