STNewAccountAuthorizeView::STNewAccountAuthorizeView(KQOAuthManager *manager, QString token,QGraphicsItem *parent) :
    QGraphicsObject(parent),m_size(0,0),m_manager(manager),m_temporaryTokenString(token)
{
    setCacheMode(DeviceCoordinateCache);
    //setFlag(ItemDoesntPropagateOpacityToChildren);
    setAcceptsHoverEvents(true);
    setFlag(ItemIsFocusable);


    QImage pix;
    pix.load(":/stella/res/AuthorizeWindow.png");

    // draw title bar and so on
    QString title=tr("Login");
    STFont *font=STFont::defaultBoldFont();

    font->drawString(pix, QPointF(14, 18-1), QColor(0,0,0,96), title);
    font->drawString(pix, QPointF(14, 18), QColor(230,230,230), title);

    m_window=new QGraphicsPixmapItem(QPixmap::fromImage(pix), this);
    m_window->setOffset(-pix.width()/2,-pix.height()/2);

    m_cancelButton=new STAuthorizeCancelButton();
    m_cancelButtonProxy=new QGraphicsProxyWidget(m_window);
    m_cancelButtonProxy->setWidget(m_cancelButton);
    m_cancelButtonProxy->setPos(QPointF(239,11)+m_window->offset());

    m_animView=new STStripeAnimationView(m_window);
    m_animView->setVisible(false);
    m_animView->setPos(10+m_window->offset().x(), 36+413-20+m_window->offset().y());
    m_animView->setSize(QSize(320, 20));

    connect(m_cancelButton, SIGNAL(clicked()),
            this, SLOT(cancelled()));
    //m_cancelButtonProxy->setCacheMode(DeviceCoordinateCache);

    m_authView=NULL;
    m_request=NULL;

    m_fadeAnimation=new STSimpleAnimator(this);
    m_cancelAnimation=new STSimpleAnimator(this);
    connect(m_fadeAnimation, SIGNAL(valueChanged(float)),
            this, SLOT(fadeAnimated(float)));
    connect(m_cancelAnimation, SIGNAL(valueChanged(float)),
            this, SLOT(fadeAnimated(float)));
    m_cancelAnimation->setValue(1.f);
    m_fadeAnimation->setValue(0);

    connect(m_manager, SIGNAL(authorizationReceived(QString,QString)),
            this, SLOT(authorizationReceived(QString,QString)));
    connect(m_manager, SIGNAL(accessTokenReceived(QString,QString)),
            this, SLOT(accessTokenReceived(QString,QString)));


}
Beispiel #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()));
}
Beispiel #3
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_);
}
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();
      }
Beispiel #5
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));
}
Beispiel #6
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);
}
Beispiel #7
0
void sync_widget::accessTokenReceived(OAuth::Token token){
    if (token.type() == OAuth::Token::AccessToken){
        qDebug() << "access success";
        oauthKeyGoogle = token.tokenString();
        oauthSecretKeyGoogle = token.tokenSecret();

        qDebug() << "Access tokens now stored. You are ready to send task requests from user's account!";
        qDebug() << "oauth token: " << oauthKeyGoogle;
        qDebug() << "oauth secret token: " << oauthSecretKeyGoogle;

        setupGTasks();
        emit googleAuthResult(true);

        getAllTaskslists();
    }
    else{
        qDebug() << "access failure";
        emit googleAuthResult(false);
    }
    disconnect(m_oauthHelper, SIGNAL(requestTokenReceived(OAuth::Token)), this, SLOT(requestTokenReceived(OAuth::Token)));
    disconnect(m_oauthHelper, SIGNAL(accessTokenReceived(OAuth::Token)), this, SLOT(accessTokenReceived(OAuth::Token)));
}
Beispiel #8
0
void sync_widget::googleClick(){

    apiReqUrl = "https://www.google.com/accounts/OAuthGetRequestToken";
    apiAuthUrl = "https://www.google.com/accounts/OAuthAuthorizeToken";
    apiAccTokUrl = "https://www.google.com/accounts/OAuthGetAccessToken";

    apiConsKeyGoogle = "545441427334.apps.googleusercontent.com";
    apiConsSecretKeyGoogle = "hLrL0maDoBGkvIsnSYQLx2Hm";
    apiKeyGoogle = "AIzaSyCyETZ3-DhV09n7X10CoKiDkXzlMukADA8";


    connect(m_oauthHelper, SIGNAL(requestTokenReceived(OAuth::Token)), this, SLOT(requestTokenReceived(OAuth::Token)));
    connect(m_oauthHelper, SIGNAL(accessTokenReceived(OAuth::Token)), this, SLOT(accessTokenReceived(OAuth::Token)));

    OAuth::Token tempToken;
    tempToken.setConsumerKey("anonymous");
    tempToken.setConsumerSecret("anonymous");
    tempToken.setCallbackUrl(QUrl("oob"));
    tempToken.setService("google");

    m_oauthHelper->getRequestToken(tempToken, QUrl(apiReqUrl + "?scope=https://www.googleapis.com/auth/tasks"));

    this->close();
}
Beispiel #9
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);
}
Beispiel #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.";
}
Beispiel #11
0
void XAuth::OnFinished(QNetworkReply* r){
    QByteArray arr(r->readAll());
    m_reply = 0;
    if(r->request().attribute(QNetworkRequest::User) != 1) {
        r->deleteLater();
        return;
    }

    QUrl dummy("http://example.com/");
    dummy.setEncodedQuery(arr);//たぶん安全なencodedQueryの使い方
    m_token_key = dummy.queryItemValue("oauth_token");
    m_token_secret = dummy.queryItemValue("oauth_token_secret");
    emit accessTokenReceived();
    //testPost();
    r->deleteLater();
}
Beispiel #12
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);
}
Beispiel #13
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()));

}
Beispiel #14
0
void OAuthWizard::onAccessTokenReceived(QString token, QString tokenSecret) {
  emit accessTokenReceived(token, tokenSecret);
}
Beispiel #15
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)));
    }