Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void TrelloApi::onTemporaryTokenReceived(QString token, QString tokenSecret)
- {
- qDebug() << "Temporary token received: " << token << tokenSecret;
- QUrl userAuthURL("https://Trello.com/1/OAuthAuthorizeToken");
- if( oauthManager->lastError() == KQOAuthManager::NoError) {
- qDebug() << "Asking for user's permission to access protected resources. Opening URL: " << userAuthURL;
- QUrl openUrl = oauthManager->getUserAuthorization(userAuthURL);
- emit urlReady(openUrl);
- }
- }
- void TrelloApi::onAuthorizationReceived(QString token, QString verifier) {
- qDebug() << "User authorization received: " << token << verifier;
- oauthManager->getUserAccessTokens(QUrl("https://Trello.com/1/OAuthGetAccessToken"));
- if( oauthManager->lastError() != KQOAuthManager::NoError) {
- emit loginComplete(false);
- }
- }
- void TrelloApi::onAccessTokenReceived(QString token, QString tokenSecret) {
- qDebug() << "Access token received: " << token << tokenSecret;
- disconnect(oauthManager, SIGNAL(accessTokenReceived(QString,QString)), this, SLOT(onAccessTokenReceived(QString,QString)));
- if(token == NULL) {
- emit loginComplete(false);
- return;
- }
- oauthSettings.setValue("oauth_token", token);
- oauthSettings.setValue("oauth_token_secret", tokenSecret);
- emit loginComplete(token.length() > 0);
- qDebug() << "Access tokens now stored.";
- }
- void TrelloApi::onAuthorizedRequestDone() {
- qDebug() << "Request sent to Trello!";
- }
- void TrelloApi::onRequestReady(QByteArray response) {
- qDebug() << "Response from the service: " << response;
- switch(oauthManager->lastError()){
- case KQOAuthManager::NoError:
- break;
- default:
- qDebug() << "There was an error";
- break;
- }
- disconnect(oauthManager, SIGNAL(requestReady(QByteArray)), this, SLOT(onRequestReady(QByteArray)));
- }
- void TrelloApi::getAccess()
- {
- connect(oauthManager, SIGNAL(temporaryTokenReceived(QString,QString)), this, SLOT(onTemporaryTokenReceived(QString, QString)));
- connect(oauthManager, SIGNAL(authorizationReceived(QString,QString)), this, SLOT( onAuthorizationReceived(QString, QString)));
- connect(oauthManager, SIGNAL(accessTokenReceived(QString,QString)), this, SLOT(onAccessTokenReceived(QString,QString)));
- connect(oauthManager, SIGNAL(requestReady(QByteArray)), this, SLOT(onRequestReady(QByteArray)));
- oauthRequest->initRequest(KQOAuthRequest::TemporaryCredentials, QUrl("https://Trello.com/1/OAuthGetRequestToken"));
- oauthRequest->setConsumerKey(CONSUMER_KEY);
- oauthRequest->setConsumerSecretKey(CONSUMER_SECRET);
- oauthManager->setHandleUserAuthorization(true);
- oauthManager->executeRequest(oauthRequest);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement