示例#1
0
void qevercloud::EvernoteOAuthWebView::onUrlChanged(const QUrl &url)
{
    // step 3: catch the rediret to our callback url (nnoauth)
    QString s = url.toString();
    if(s.contains("nnoauth?") && s.contains("?oauth_token=")) {
        if(s.contains("&oauth_verifier=")) { // success
            QString token = s.mid(s.indexOf("?oauth_token=") + QString("?oauth_token=").length());

            // step 4: acquire permanent token
            ReplyFetcher* replyFetcher = new ReplyFetcher();
            connect(replyFetcher, SIGNAL(replyFetched(QObject*)), this, SLOT(permanentFinished(QObject*)));
            QUrl url(oauthUrlBase_ + QString("&oauth_token=%1").arg(token));
            replyFetcher->start(page()->networkAccessManager(), url);
        } else {
示例#2
0
void qevercloud::EvernoteOAuthWebView::authenticate(QString host, QString consumerKey, QString consumerSecret)
{
    host_ = host;
    isSucceeded_ = false;
    this->setHtml("");
    this->history()->clear();

    qint64 timestamp = QDateTime::currentMSecsSinceEpoch()/1000;
    qint64 nonce = nonceGenerator()();
    oauthUrlBase_ = QStringLiteral("https://%1/oauth?oauth_consumer_key=%2&oauth_signature=%3&oauth_signature_method=PLAINTEXT&oauth_timestamp=%4&oauth_nonce=%5")
            .arg(host).arg(consumerKey).arg(consumerSecret).arg(timestamp).arg(nonce);

    // step 1: acquire temporary token
    ReplyFetcher* replyFetcher = new ReplyFetcher();
    connect(replyFetcher, &ReplyFetcher::replyFetched, this, &EvernoteOAuthWebView::temporaryFinished);
    QUrl url(oauthUrlBase_ + QStringLiteral("&oauth_callback=nnoauth"));
    replyFetcher->start(page()->networkAccessManager(), url);
}
示例#3
0
void qevercloud::EvernoteOAuthWebView::onUrlChanged(const QUrl &url)
{
    // step 3: catch the rediret to our callback url (nnoauth)
    QString s = url.toString();
    QString oauthMarker = QStringLiteral("?oauth_token=");
    if(s.contains(QStringLiteral("nnoauth?")) && s.contains(oauthMarker)) {
        if(s.contains(QStringLiteral("&oauth_verifier="))) { // success
            QString token = s.mid(s.indexOf(oauthMarker) + oauthMarker.length());

            // step 4: acquire permanent token
            ReplyFetcher* replyFetcher = new ReplyFetcher();
            connect(replyFetcher, &ReplyFetcher::replyFetched, this, &EvernoteOAuthWebView::permanentFinished);
            QUrl url(oauthUrlBase_ + QStringLiteral("&oauth_token=%1").arg(token));
            replyFetcher->start(page()->networkAccessManager(), url);
        } else {
            setError(QStringLiteral("Authentification failed."));
        }
        disconnect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(onUrlChanged(QUrl)));
        QMetaObject::invokeMethod(this, "clearHtml", Qt::QueuedConnection);
    }
}
示例#4
0
void qevercloud::AsyncResult::start()
{
    ReplyFetcher* f = new ReplyFetcher;
    QObject::connect(f, &ReplyFetcher::replyFetched, this, &AsyncResult::onReplyFetched);
    f->start(evernoteNetworkAccessManager(), request_, postData_);
}