Ejemplo n.º 1
0
void TwitterInterface::GetAccess ()
{
#ifdef WP_DEBUG
    qDebug() << Q_FUNC_INFO;
#endif
    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 (authorizationPageRequested (QUrl)),
             this,
             SLOT (onAuthorizationPageRequested (QUrl)));

    OAuthRequest_->initRequest (KQOAuthRequest::TemporaryCredentials,
                                QUrl ("https://api.twitter.com/oauth/request_token"));
    OAuthRequest_->setConsumerKey (ConsumerKey_);
    OAuthRequest_->setConsumerSecretKey (ConsumerKeySecret_);
    OAuthManager_->setHandleUserAuthorization (true);
    OAuthManager_->setHandleAuthorizationPageOpening (false);

    OAuthManager_->executeRequest (OAuthRequest_);
}
Ejemplo n.º 2
0
void Kaqtoos::setupConnections()
{
	// OAUTH
	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)));

	// Network
	connect(&downloadManager, SIGNAL(getDownload(QBuffer *, const QString &)),
	        this, SLOT(receiveBuffer(QBuffer *, const QString &)));

	// UI
	connect(connectAction, SIGNAL(triggered()), this, SLOT(getAccess()));
	connect(disconnectAction, SIGNAL(triggered()), this, SLOT(deleteUserOAuthConnection()));

	connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
	connect(aboutAction, SIGNAL(triggered()), this, SLOT(openAbout()));
}
Ejemplo n.º 3
0
LoginManager::LoginManager(QObject* parent)
 : QObject(parent)
      {
      _oauthManager = new KQOAuthManager(this);
      connect(_oauthManager, SIGNAL(accessTokenReceived(QString, QString)),
            this, SLOT(onAccessTokenReceived(QString, QString)));
      connect(_oauthManager, SIGNAL(authorizedRequestDone()),
            this, SLOT(onAuthorizedRequestDone()));
      QByteArray ba;
      ba.resize(32);
      ba[0] = 0x68; ba[1] = 0x74; ba[2] = 0x55; ba[3] = 0x38;
      ba[4] = 0x48; ba[5] = 0x45; ba[6] = 0x4c; ba[7] = 0x45;
      ba[8] = 0x4d; ba[9] = 0x47; ba[10] = 0x43; ba[11] = 0x55;
      ba[12] = 0x6e; ba[13] = 0x6f; ba[14] = 0x53; ba[15] = 0x54;
      ba[16] = 0x38; ba[17] = 0x67; ba[18] = 0x6b; ba[19] = 0x78;
      ba[20] = 0x34; ba[21] = 0x77; ba[22] = 0x33; ba[23] = 0x69;
      ba[24] = 0x52; ba[25] = 0x63; ba[26] = 0x64; ba[27] = 0x6e;
      ba[28] = 0x41; ba[29] = 0x6a; ba[30] = 0x37; ba[31] = 0x51;
      _consumerKey = QString(ba);
      ba[0] = 0x52; ba[1] = 0x50; ba[2] = 0x75; ba[3] = 0x32; 
      ba[4] = 0x79; ba[5] = 0x52; ba[6] = 0x69; ba[7] = 0x52;
      ba[8] = 0x6f; ba[9] = 0x58; ba[10] = 0x53; ba[11] = 0x41;
      ba[12] = 0x48; ba[13] = 0x6d; ba[14] = 0x4a; ba[15] = 0x6f;
      ba[16] = 0x6b; ba[17] = 0x61; ba[18] = 0x62; ba[19] = 0x59;
      ba[20] = 0x35; ba[21] = 0x37; ba[22] = 0x59; ba[23] = 0x74;
      ba[24] = 0x66; ba[25] = 0x51; ba[26] = 0x5a; ba[27] = 0x36;
      ba[28] = 0x77; ba[29] = 0x35; ba[30] = 0x69; ba[31] = 0x77;
      _consumerSecret  = QString(ba);
      load();
      }
Ejemplo n.º 4
0
void sync_widget::getAccess()  {
    connect(m_oauthHelper, SIGNAL(requestTokenReceived(OAuth::Token)), this, SLOT(onTemporaryTokenReceived(OAuth::Token)));
    connect(m_oauthHelper, SIGNAL(accessTokenReceived(OAuth::Token)), this, SLOT(onAccessTokenReceived(OAuth::Token)));

    OAuth::Token tempToken;

    tempToken.setConsumerKey(apiConsKey);
    tempToken.setConsumerSecret(apiConsSecretKey);
    tempToken.setService("dbox");

    m_oauthHelper->getRequestToken(tempToken, QUrl(apiReqUrl));
}
Ejemplo n.º 5
0
void VimeoAuth::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://vimeo.com/oauth/request_token"));
    oauthRequest->setConsumerKey(CONSUMER_KEY);
    oauthRequest->setConsumerSecretKey(CONSUMER_SECRET);
    oauthManager->setHandleUserAuthorization(true);
    oauthManager->executeRequest(oauthRequest);
}
Ejemplo n.º 6
0
void OAuthWizard::getOAuthAccess() {
  notifyMessage(tr("Authorising user ..."));

  connect(m_oam, SIGNAL(temporaryTokenReceived(QString, QString)),
          this, SLOT(onTemporaryTokenReceived(QString, QString)));
  connect(m_oam, SIGNAL(accessTokenReceived(QString, QString)),
          this, SLOT(onAccessTokenReceived(QString, QString)));

  m_oar->initRequest(KQOAuthRequest::TemporaryCredentials,
                     QUrl(m_server+"/oauth/request_token"));
  m_oar->setConsumerKey(m_clientId);
  m_oar->setConsumerSecretKey(m_clientSecret);

  m_oam->executeRequest(m_oar);
}
Ejemplo n.º 7
0
void TwitterInterface::Xauth ()
{
#ifdef WP_DEBUG
    qDebug() << Q_FUNC_INFO;
#endif
    connect (OAuthManager_,
             SIGNAL (accessTokenReceived (QString, QString)),
             this,
             SLOT (onAccessTokenReceived (QString, QString)));

    KQOAuthRequest_XAuth *oauthRequest = new KQOAuthRequest_XAuth (this);
    oauthRequest->initRequest (KQOAuthRequest::AccessToken,
                               QUrl ("https://api.twitter.com/oauth/access_token"));
    oauthRequest->setConsumerKey (XmlSettingsManager::Instance ()->
                                  property ("consumer_key").toString ());
    oauthRequest->setConsumerSecretKey (XmlSettingsManager::Instance ()->
                                        property ("consumer_key_secret").toString ());
    OAuthManager_->executeRequest (oauthRequest);
}
Ejemplo n.º 8
0
TwitterAPI::TwitterAPI(QObject *parent) :
        QObject(parent)
        //QMainWindow(parent),
        //ui_main(new Ui::MainWindow)
{
    oauthManager = new KQOAuthManager(this);
    oauthManager->setHandleUserAuthorization(false);

    connect(oauthManager, SIGNAL(temporaryTokenReceived(QString,QString)),
            this, SLOT(onTemporaryTokenReceived(QString,QString)));

    connect(oauthManager, SIGNAL(accessTokenReceived(QString,QString)),
            this, SLOT(onAccessTokenReceived(QString,QString)));

//    connect(this->oauthManager, SIGNAL(requestReady(QByteArray, QNetworkReply *)),
//            this, SLOT(responseHandler(QByteArray, QNetworkReply *)));

    connect(oauthManager, SIGNAL(requestReady(QNetworkReply *, QByteArray)),
                this, SLOT(responseHandler(QNetworkReply *, QByteArray)));

    connect(oauthManager, SIGNAL(authorizedRequestDone()),
            this, SLOT(onAuthorizedRequestDone()));

}
Ejemplo n.º 9
0
OAuthDialog::OAuthDialog(Context *context, OAuthSite site) :
    context(context), site(site)
{

    setAttribute(Qt::WA_DeleteOnClose);
    setWindowTitle(tr("OAuth"));

    // check if SSL is available - if not - message and end
    if (!QSslSocket::supportsSsl()) {
        QString text = QString(tr("SSL Security Libraries required for 'Authorise' are missing in this installation."));
        QMessageBox sslMissing(QMessageBox::Critical, tr("Authorization Error"), text);
        sslMissing.exec();
        noSSLlib = true;
        return;
    }

    // SSL is available - so authorisation can take place
    noSSLlib = false;

    layout = new QVBoxLayout();
    layout->setSpacing(0);
    layout->setContentsMargins(2,0,2,2);
    setLayout(layout);


    #if QT_VERSION < 0x050000 || !defined(Q_OS_MAC)
    view = new QWebView();
    #else
    view = new QWebEngineView();
    #endif

    view->setContentsMargins(0,0,0,0);
    view->page()->view()->setContentsMargins(0,0,0,0);
    view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    view->setAcceptDrops(false);
    layout->addWidget(view);

    QString urlstr = "";
    if (site == STRAVA) {
        urlstr = QString("https://www.strava.com/oauth/authorize?");
        urlstr.append("client_id=").append(GC_STRAVA_CLIENT_ID).append("&");
        urlstr.append("scope=view_private,write&");
        urlstr.append("redirect_uri=http://www.goldencheetah.org/&");
        urlstr.append("response_type=code&");
        urlstr.append("approval_prompt=force");

    } else if (site == DROPBOX) {

        urlstr = QString("https://www.dropbox.com/1/oauth2/authorize?");

#ifdef GC_DROPBOX_CLIENT_ID
        urlstr.append("client_id=").append(GC_DROPBOX_CLIENT_ID).append("&");
#endif
        urlstr.append("redirect_uri=https://goldencheetah.github.io/blank.html&");
        urlstr.append("response_type=code&");
        urlstr.append("force_reapprove=true");

    } else if (site == TWITTER) {

#ifdef GC_HAVE_KQOAUTH
        oauthRequest = new KQOAuthRequest;
        oauthManager = new KQOAuthManager(this);

        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)));

        connect(oauthManager, SIGNAL(authorizationPageRequested(QUrl)),
                this, SLOT(onAuthorizationPageRequested(QUrl)));


        oauthRequest->initRequest(KQOAuthRequest::TemporaryCredentials, QUrl("https://api.twitter.com/oauth/request_token"));

        oauthRequest->setConsumerKey(GC_TWITTER_CONSUMER_KEY);
        oauthRequest->setConsumerSecretKey(GC_TWITTER_CONSUMER_SECRET);

        oauthManager->setHandleUserAuthorization(true);
        oauthManager->setHandleAuthorizationPageOpening(false);

        oauthManager->executeRequest(oauthRequest);

#endif
    } else if (site == CYCLING_ANALYTICS) {

        urlstr = QString("https://www.cyclinganalytics.com/api/auth?");
        urlstr.append("client_id=").append(GC_CYCLINGANALYTICS_CLIENT_ID).append("&");
        urlstr.append("scope=modify_rides&");
        urlstr.append("redirect_uri=http://www.goldencheetah.org/&");
        urlstr.append("response_type=code&");
        urlstr.append("approval_prompt=force");

    } else if (site == GOOGLE_CALENDAR) {

        // OAUTH 2.0 - Google flow for installed applications
        urlstr = QString("https://accounts.google.com/o/oauth2/auth?");
        urlstr.append("scope=https://www.googleapis.com/auth/calendar&");
        urlstr.append("redirect_uri=urn:ietf:wg:oauth:2.0:oob&");
        urlstr.append("response_type=code&");
        urlstr.append("client_id=").append(GC_GOOGLE_CALENDAR_CLIENT_ID);
    }

    // different process to get the token for STRAVA, CYCLINGANALYTICS vs. TWITTER
    if (site == DROPBOX || site == STRAVA || site == CYCLING_ANALYTICS || site == GOOGLE_CALENDAR ) {


        url = QUrl(urlstr);
        view->setUrl(url);

        // connects
        connect(view, SIGNAL(urlChanged(const QUrl&)), this, SLOT(urlChanged(const QUrl&)));
        connect(view, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
    }
Ejemplo n.º 10
0
void VimeoAuth::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.";
}