Commit ae8f4c7a authored by Jesus Fernandez's avatar Jesus Fernandez

URL variable name changed.

parent e3481f18
......@@ -79,7 +79,7 @@ public:
void setStatus(QAbstractOAuth::Status status);
QUrl authenticateUrl;
QUrl authorizationUrl;
QVariantMap extraTokens;
QAbstractOAuth::Status status;
QNetworkAccessManager::Operation operation;
......
......@@ -73,6 +73,12 @@ public:
QOAuth1Private(QNetworkAccessManager *networkAccessManager);
QString verifier;
QUrl temporaryCredentialsUrl;
QUrl tokenCredentialsUrl;
QOAuth1::Credential clientCredentials;
QOAuth1::Credential token;
QOAuth1::SignatureMethod signatureMethod = QOAuth1::SignatureMethod::Hmac_Sha1;
const QString oauthVersion = QStringLiteral("1.0");
// private slots
void _q_onTokenRequestFinished();
......@@ -93,12 +99,6 @@ public:
const QOAuth1::Credential &token,
const QVariantMap &additionalParameters);
QUrl requestTokenUrl;
QUrl authorizationGrantUrl;
QOAuth1::Credential clientCredentials;
QOAuth1::Credential token;
QOAuth1::SignatureMethod signatureMethod = QOAuth1::SignatureMethod::Hmac_Sha1;
const QString oauthVersion = QStringLiteral("1.0");
QString signatureMethodString() const;
static QString operationName(QNetworkAccessManager::Operation op);
......
......@@ -108,18 +108,18 @@ QAbstractOAuth::Status QAbstractOAuth::status() const
return d->status;
}
QUrl QAbstractOAuth::authorizeUrl() const
QUrl QAbstractOAuth::authorizationUrl() const
{
Q_D(const QAbstractOAuth);
return d->authenticateUrl;
return d->authorizationUrl;
}
void QAbstractOAuth::setAuthorizeUrl(const QUrl &url)
void QAbstractOAuth::setAuthorizationUrl(const QUrl &url)
{
Q_D(QAbstractOAuth);
if (d->authenticateUrl != url) {
d->authenticateUrl = url;
Q_EMIT authorizeUrlChanged(url);
if (d->authorizationUrl != url) {
d->authorizationUrl = url;
Q_EMIT authorizationUrlChanged(url);
}
}
......
......@@ -42,10 +42,8 @@
#ifndef QT_NO_HTTP
#include <QtCore/qpair.h>
#include <QtCore/qstring.h>
#include <QtCore/qobject.h>
#include <QtCore/qvariant.h>
#include <QtNetwork/qnetworkaccessmanager.h>
......@@ -60,6 +58,7 @@
QT_BEGIN_NAMESPACE
class QUrl;
class QString;
class QByteArray;
class QNetworkReply;
class QNetworkRequest;
......@@ -81,8 +80,6 @@ public:
Credential(const QString &credentialKey);
};
virtual ~QAbstractOAuth();
enum class Status {
NotAuthenticated,
TemporaryTokenReceived,
......@@ -95,8 +92,6 @@ public:
RequestingAccessToken
};
typedef std::function<void(Stage, QVariantMap*)> ModifyParametersFunction;
enum class Error {
NoError,
NetworkError,
......@@ -107,10 +102,15 @@ public:
OAuthCallbackNotVerified
};
typedef std::function<void(Stage, QVariantMap*)> ModifyParametersFunction;
virtual ~QAbstractOAuth();
Status status() const;
QUrl authorizeUrl() const;
void setAuthorizeUrl(const QUrl &url);
// Resource Owner Authorization: https://tools.ietf.org/html/rfc5849#section-2.2
QUrl authorizationUrl() const;
void setAuthorizationUrl(const QUrl &url);
QVariantMap extraTokens() const;
......@@ -129,19 +129,12 @@ public Q_SLOTS:
virtual void grant() = 0;
Q_SIGNALS:
void granted();
void requestFailed(const Error error);
void statusChanged(Status status);
void requestTokenUrlChanged(const QUrl &url);
void authorizationGrantUrlChanged(const QUrl &url);
void authorizeUrlChanged(const QUrl &url);
void authorizationUrlChanged(const QUrl &url);
void extraTokensChanged(const QVariantMap &tokens);
void authenticationRequested(const QUrl &url);
void granted();
void authorizationRequested(const QUrl &url);
protected:
explicit QAbstractOAuth(QAbstractOAuthPrivate &, QObject *parent = nullptr);
......
......@@ -307,63 +307,63 @@ QOAuth1::QOAuth1(const Credential &consumerToken, QNetworkAccessManager *manager
QOAuth1::~QOAuth1()
{}
QUrl QOAuth1::requestTokenUrl() const
QOAuth1::Credential QOAuth1::clientCredentials() const
{
Q_D(const QOAuth1);
return d->requestTokenUrl;
return d->clientCredentials;
}
void QOAuth1::setRequestTokenUrl(const QUrl &url)
void QOAuth1::setClientCredentials(const QOAuth1::Credential &clientCredentials)
{
Q_D(QOAuth1);
if (d->requestTokenUrl != url) {
d->requestTokenUrl = url;
Q_EMIT requestTokenUrlChanged(url);
if (d->clientCredentials != clientCredentials) {
d->clientCredentials = clientCredentials;
Q_EMIT clientCredentialsChanged(clientCredentials);
}
}
QUrl QOAuth1::authorizationGrantUrl() const
QUrl QOAuth1::temporaryCredentialsUrl() const
{
Q_D(const QOAuth1);
return d->authorizationGrantUrl;
return d->temporaryCredentialsUrl;
}
void QOAuth1::setAuthorizationGrantUrl(const QUrl &url)
void QOAuth1::setTemporaryCredentialsUrl(const QUrl &url)
{
Q_D(QOAuth1);
if (d->authorizationGrantUrl != url) {
d->authorizationGrantUrl = url;
Q_EMIT authorizationGrantUrlChanged(url);
if (d->temporaryCredentialsUrl != url) {
d->temporaryCredentialsUrl = url;
Q_EMIT temporaryCredentialsUrlChanged(url);
}
}
QOAuth1::SignatureMethod QOAuth1::signatureMethod() const
QUrl QOAuth1::tokenCredentialsUrl() const
{
Q_D(const QOAuth1);
return d->signatureMethod;
return d->tokenCredentialsUrl;
}
void QOAuth1::setSignatureMethod(QOAuth1::SignatureMethod value)
void QOAuth1::setTokenCredentialsUrl(const QUrl &url)
{
Q_D(QOAuth1);
if (d->signatureMethod != value) {
d->signatureMethod = value;
Q_EMIT signatureMethodChanged(value);
if (d->tokenCredentialsUrl != url) {
d->tokenCredentialsUrl = url;
Q_EMIT tokenCredentialsUrlChanged(url);
}
}
QOAuth1::Credential QOAuth1::clientCredentials() const
QOAuth1::SignatureMethod QOAuth1::signatureMethod() const
{
Q_D(const QOAuth1);
return d->clientCredentials;
return d->signatureMethod;
}
void QOAuth1::setClientCredentials(const QOAuth1::Credential &clientCredentials)
void QOAuth1::setSignatureMethod(QOAuth1::SignatureMethod value)
{
Q_D(QOAuth1);
if (d->clientCredentials != clientCredentials) {
d->clientCredentials = clientCredentials;
Q_EMIT clientCredentialsChanged(clientCredentials);
if (d->signatureMethod != value) {
d->signatureMethod = value;
Q_EMIT signatureMethodChanged(value);
}
}
......@@ -457,21 +457,24 @@ QNetworkReply *QOAuth1::requestTokenCredentials(QNetworkAccessManager::Operation
return d->requestToken(operation, url, temporaryCredentials, parameters);
}
QByteArray QOAuth1::generateSignature(const QVariantMap &parameters, const QUrl &url, QNetworkAccessManager::Operation operation)
QByteArray QOAuth1::generateSignature(const QVariantMap &parameters,
const QUrl &url,
QNetworkAccessManager::Operation operation)
{
Q_D(QOAuth1);
QByteArray signature;
QByteArray ret;
if (signatureMethod() == SignatureMethod::Hmac_Sha1) {
signature = sign(parameters, url, operation, d->clientCredentials.secret, d->token.secret);
ret = signature(parameters, url, operation, d->clientCredentials.secret, d->token.secret);
} else if (signatureMethod() == SignatureMethod::PlainText) {
signature.append(d->clientCredentials.key.toUtf8());
signature.append('&');
signature.append(d->clientCredentials.secret.toUtf8());
ret.append(d->clientCredentials.key.toUtf8());
ret.append('&');
ret.append(d->clientCredentials.secret.toUtf8());
}
return signature;
return ret;
}
void QOAuth1::setup(QNetworkRequest *request, const QVariantMap &signingParameters,
void QOAuth1::setup(QNetworkRequest *request,
const QVariantMap &signingParameters,
QNetworkAccessManager::Operation operation)
{
Q_D(const QOAuth1);
......@@ -558,9 +561,9 @@ QByteArray QOAuth1::nonce()
return u.toUtf8();
}
QByteArray QOAuth1::signatureBase(const QVariantMap &parameters,
const QUrl &url,
QNetworkAccessManager::Operation op)
QByteArray QOAuth1::signatureBaseString(const QVariantMap &parameters,
const QUrl &url,
QNetworkAccessManager::Operation op)
{
QByteArray base;
......@@ -582,13 +585,13 @@ QByteArray QOAuth1::encodeHeaders(const QVariantMap &headers)
return QUrl::toPercentEncoding(QString::fromLatin1(parameterString(headers)));
}
QByteArray QOAuth1::sign(const QVariantMap &parameters,
const QUrl &url,
QNetworkAccessManager::Operation op,
const QString &consumerSecret,
const QString &tokenSecret)
QByteArray QOAuth1::signature(const QVariantMap &parameters,
const QUrl &url,
QNetworkAccessManager::Operation op,
const QString &consumerSecret,
const QString &tokenSecret)
{
const QByteArray baseString = signatureBase(parameters, url, op);
const QByteArray baseString = signatureBaseString(parameters, url, op);
QByteArray secret;
secret.append(QUrl::toPercentEncoding(consumerSecret));
......@@ -624,10 +627,10 @@ void QOAuth1::grant()
Q_D(QOAuth1);
typedef QOAuth1Private::OAuth1KeyString Key;
if (d->requestTokenUrl.isEmpty()) {
if (d->temporaryCredentialsUrl.isEmpty()) {
qCritical("QOAuth1::grant: requestTokenUrl is empty");
return;
} else if (d->authorizationGrantUrl.isEmpty()) {
} else if (d->tokenCredentialsUrl.isEmpty()) {
qCritical("QOAuth1::grant: authorizationGrantUrl is empty");
return;
}
......@@ -637,20 +640,20 @@ void QOAuth1::grant()
if (d->status == Status::NotAuthenticated) {
d->setStatus(Status::TemporaryTokenReceived);
if (!d->authenticateUrl.isEmpty()) {
if (!d->authorizationUrl.isEmpty()) {
QVariantMap parameters;
parameters.insert(Key::oauthToken, d->token.key);
if (d->modifyParametersFunction)
d->modifyParametersFunction(Stage::RequestingAuthorization, &parameters);
QUrl url = d->authenticateUrl;
QUrl url = d->authorizationUrl;
url.setQuery(QAbstractOAuthPrivate::createQuery(parameters));
Q_EMIT authenticationRequested(url);
Q_EMIT authorizationRequested(url);
}
else {
// try upgrading token without verifier
requestTokenCredentials(QNetworkAccessManager::PostOperation,
d->authorizationGrantUrl,
d->tokenCredentialsUrl,
d->token);
}
} else if (d->status == Status::TemporaryTokenReceived) {
......@@ -673,7 +676,7 @@ void QOAuth1::grant()
}
// requesting temporary credentials
requestTemporaryCredentials(QNetworkAccessManager::PostOperation, d->requestTokenUrl);
requestTemporaryCredentials(QNetworkAccessManager::PostOperation, d->temporaryCredentialsUrl);
}
void QOAuth1::continueGrantWithVerifier(const QString &verifier)
......@@ -684,7 +687,7 @@ void QOAuth1::continueGrantWithVerifier(const QString &verifier)
QVariantMap parameters;
parameters.insert(Key::oauthVerifier, verifier);
requestTokenCredentials(QNetworkAccessManager::PostOperation,
d->authorizationGrantUrl,
d->tokenCredentialsUrl,
d->token,
parameters);
}
......
......@@ -52,7 +52,8 @@ class OAUTH_EXPORT QOAuth1: public QAbstractOAuth
Q_OBJECT
public:
struct OAUTH_EXPORT Credential : QAbstractOAuth::Credential {
struct OAUTH_EXPORT Credential : QAbstractOAuth::Credential
{
QString secret;
Credential();
......@@ -72,27 +73,28 @@ public:
explicit QOAuth1(QNetworkAccessManager *manager,
QObject *parent = nullptr);
explicit QOAuth1(const Credential &clientCredentials,
QNetworkAccessManager *manager,
QObject *parent = nullptr);
QOAuth1(const Credential &clientCredentials,
QNetworkAccessManager *manager,
QObject *parent = nullptr);
virtual ~QOAuth1();
QUrl requestTokenUrl() const;
void setRequestTokenUrl(const QUrl &url);
// Client credentials
QOAuth1::Credential clientCredentials() const;
void setClientCredentials(const QOAuth1::Credential &clientCredentials);
QUrl authorizationGrantUrl() const;
void setAuthorizationGrantUrl(const QUrl &url);
// Temporary Credentials: https://tools.ietf.org/html/rfc5849#section-2.1
QUrl temporaryCredentialsUrl() const;
void setTemporaryCredentialsUrl(const QUrl &url);
// Token Credentials: https://tools.ietf.org/html/rfc5849#section-2.3
QUrl tokenCredentialsUrl() const;
void setTokenCredentialsUrl(const QUrl &url);
// Signature method: https://tools.ietf.org/html/rfc5849#section-3.4
SignatureMethod signatureMethod() const;
void setSignatureMethod(SignatureMethod value);
// Client credentials
QOAuth1::Credential clientCredentials() const;
void setClientCredentials(const QOAuth1::Credential &clientCredentials);
// Token credentials: https://tools.ietf.org/html/rfc5849#section-2.3
QOAuth1::Credential token() const;
void setToken(const QOAuth1::Credential &token);
......@@ -112,6 +114,8 @@ Q_SIGNALS:
void signatureMethodChanged(SignatureMethod method);
void clientCredentialsChanged(const QOAuth1::Credential &credential);
void tokenChanged(const QOAuth1::Credential &token);
void temporaryCredentialsUrlChanged(const QUrl &url);
void tokenCredentialsUrlChanged(const QUrl &url);
protected:
QNetworkReply *requestTemporaryCredentials(QNetworkAccessManager::Operation operation,
......@@ -133,18 +137,20 @@ protected:
static QMap<QString, QString> parseResponse(const QByteArray &response);
static QByteArray parameterString(const QVariantMap &parameters);
// Nonce: https://tools.ietf.org/html/rfc5849#section-3.3
static QByteArray nonce();
static QByteArray encodeHeaders(const QVariantMap &headers);
static QByteArray generateAuthorizationHeader(const QVariantMap &oauthParams);
static QByteArray signatureBase(const QVariantMap &parameters,
// Signature Base String: https://tools.ietf.org/html/rfc5849#section-3.4.1
static QByteArray signatureBaseString(const QVariantMap &parameters,
const QUrl &url,
QNetworkAccessManager::Operation op);
static QByteArray sign(const QVariantMap &parameters,
const QUrl &url,
QNetworkAccessManager::Operation op,
const QString &consumerSecret,
const QString &tokenSecret);
// Signature: https://tools.ietf.org/html/rfc5849#section-3.4
static QByteArray signature(const QVariantMap &parameters,
const QUrl &url,
QNetworkAccessManager::Operation op,
const QString &consumerSecret,
const QString &tokenSecret);
private:
Q_DISABLE_COPY(QOAuth1)
......
......@@ -163,7 +163,7 @@ QOAuth2AuthorizationCodeFlow::QOAuth2AuthorizationCodeFlow(const QUrl &authentic
: QAbstractOAuth2(*new QOAuth2AuthorizationCodeFlowPrivate(manager, port), parent)
{
Q_D(QOAuth2AuthorizationCodeFlow);
d->authenticateUrl = authenticateUrl;
d->authorizationUrl = authenticateUrl;
d->accessTokenUrl = accessTokenUrl;
}
......@@ -177,7 +177,7 @@ QOAuth2AuthorizationCodeFlow::QOAuth2AuthorizationCodeFlow(const QString &consum
{
Q_D(QOAuth2AuthorizationCodeFlow);
d->networkAccessManager = manager;
d->authenticateUrl = authenticateUrl;
d->authorizationUrl = authenticateUrl;
d->accessTokenUrl = accessTokenUrl;
d->consumer = consumerKey;
}
......@@ -213,7 +213,7 @@ void QOAuth2AuthorizationCodeFlow::setAccessTokenUrl(const QUrl &accessTokenUrl)
void QOAuth2AuthorizationCodeFlow::grant()
{
const QUrl url = buildAuthenticateUrl();
Q_EMIT authenticationRequested(url);
Q_EMIT authorizationRequested(url);
}
QUrl QOAuth2AuthorizationCodeFlow::buildAuthenticateUrl(const QVariantMap &parameters)
......@@ -224,7 +224,7 @@ QUrl QOAuth2AuthorizationCodeFlow::buildAuthenticateUrl(const QVariantMap &param
const QString state = QAbstractOAuth2Private::generateRandomState();
QVariantMap p(parameters);
QUrl url(d->authenticateUrl);
QUrl url(d->authorizationUrl);
p.insert(Key::responseType, responseType());
p.insert(Key::clientId, d->consumer.key);
p.insert(Key::redirectUri, callback());
......
......@@ -60,23 +60,23 @@ public:
quint16 port = 0,
QObject *parent = nullptr);
explicit QOAuth2AuthorizationCodeFlow(const QString &consumerToken,
QNetworkAccessManager *manager,
quint16 port = 0,
QObject *parent = nullptr);
explicit QOAuth2AuthorizationCodeFlow(const QUrl &authorizeUrl,
const QUrl &accessTokenUrl,
QNetworkAccessManager *manager,
quint16 port = 0,
QObject *parent = nullptr);
explicit QOAuth2AuthorizationCodeFlow(const QString &consumerToken,
const QUrl &authorizeUrl,
const QUrl &accessTokenUrl,
QNetworkAccessManager *manager,
quint16 port = 0,
QObject *parent = nullptr);
QOAuth2AuthorizationCodeFlow(const QString &consumerToken,
QNetworkAccessManager *manager,
quint16 port = 0,
QObject *parent = nullptr);
QOAuth2AuthorizationCodeFlow(const QUrl &authorizationUrl,
const QUrl &accessTokenUrl,
QNetworkAccessManager *manager,
quint16 port = 0,
QObject *parent = nullptr);
QOAuth2AuthorizationCodeFlow(const QString &consumerToken,
const QUrl &authorizationUrl,
const QUrl &accessTokenUrl,
QNetworkAccessManager *manager,
quint16 port = 0,
QObject *parent = nullptr);
virtual ~QOAuth2AuthorizationCodeFlow();
......
......@@ -67,14 +67,14 @@ QOAuth2ImplicitGrantFlow::QOAuth2ImplicitGrantFlow(QNetworkAccessManager *manage
d->networkAccessManager = manager;
}
QOAuth2ImplicitGrantFlow::QOAuth2ImplicitGrantFlow(const QString &consumerKey,
QOAuth2ImplicitGrantFlow::QOAuth2ImplicitGrantFlow(const QString &consumerToken,
QNetworkAccessManager *manager,
QObject *parent)
: QAbstractOAuth2(*new QOAuth2ImplicitGrantFlowPrivate(manager), parent)
{
Q_D(QOAuth2ImplicitGrantFlow);
d->networkAccessManager = manager;
d->consumer = consumerKey;
d->consumer = consumerToken;
}
QOAuth2ImplicitGrantFlow::~QOAuth2ImplicitGrantFlow()
......@@ -94,7 +94,7 @@ void QOAuth2ImplicitGrantFlow::grant()
{
const QString state = QAbstractOAuth2Private::generateRandomState();
const QUrl url = authorizationRequestUrl(state);
Q_EMIT authenticationRequested(url);
Q_EMIT authorizationRequested(url);
}
QUrl QOAuth2ImplicitGrantFlow::authorizationRequestUrl(const QString &state) const
......@@ -102,9 +102,8 @@ QUrl QOAuth2ImplicitGrantFlow::authorizationRequestUrl(const QString &state) con
Q_D(const QOAuth2ImplicitGrantFlow);
typedef QAbstractOAuth2Private::OAuth2KeyString Key;
QUrlQuery query;
QVariantMap parameters;
QUrl url(d->authenticateUrl);
QUrl url(d->authorizationUrl);
parameters.insert(Key::responseType, responseType());
parameters.insert(Key::clientId, d->consumer.key);
parameters.insert(Key::redirectUri, callback());
......
......@@ -54,9 +54,9 @@ class OAUTH_EXPORT QOAuth2ImplicitGrantFlow : public QAbstractOAuth2
public:
explicit QOAuth2ImplicitGrantFlow(QNetworkAccessManager *manager,
QObject *parent = nullptr);
explicit QOAuth2ImplicitGrantFlow(const QString &consumerToken,
QNetworkAccessManager *manager,
QObject *parent);
QOAuth2ImplicitGrantFlow(const QString &consumerToken,
QNetworkAccessManager *manager,
QObject *parent = nullptr);
virtual ~QOAuth2ImplicitGrantFlow();
......
......@@ -140,7 +140,7 @@ void RedditWrapper::init()
RedditWrapper::RedditOAuth::RedditOAuth(QNetworkAccessManager *manager)
: QOAuth2AuthorizationCodeFlow(manager, 1337)
{
setAuthorizeUrl(QUrl("https://www.reddit.com/api/v1/authorize"));
setAuthorizationUrl(QUrl("https://www.reddit.com/api/v1/authorize"));
setAccessTokenUrl(QUrl("https://www.reddit.com/api/v1/access_token"));
}
......
......@@ -70,11 +70,11 @@ void Twitter::init()
{
replyHandler = new QOAuthHttpServerReplyHandler(this);
setReplyHandler(replyHandler);
setRequestTokenUrl(QUrl("https://api.twitter.com/oauth/request_token"));
setAuthorizeUrl(QUrl("https://api.twitter.com/oauth/authenticate"));
setAuthorizationGrantUrl(QUrl("https://api.twitter.com/oauth/access_token"));
setTemporaryCredentialsUrl(QUrl("https://api.twitter.com/oauth/request_token"));
setAuthorizationUrl(QUrl("https://api.twitter.com/oauth/authenticate"));
setTokenCredentialsUrl(QUrl("https://api.twitter.com/oauth/access_token"));
connect(this, &QAbstractOAuth::authenticationRequested, [&](QUrl url) {
connect(this, &QAbstractOAuth::authorizationRequested, [&](QUrl url) {
QUrlQuery query(url);
query.addQueryItem("force_login", "true"); // Forces the user to enter their credentials to
......
......@@ -209,8 +209,8 @@ void tst_QOAuth::createSignature()
struct OAuthSubClass : QOAuth1 {
using QOAuth1::parameterString;
using QOAuth1::signatureBase;
using QOAuth1::sign;
using QOAuth1::signatureBaseString;
using QOAuth1::signature;
};
// Creating parameter string
......@@ -236,7 +236,7 @@ void tst_QOAuth::createSignature()
// Collecting parameters
oauthParams.unite(otherParametersFromData);
signatureBase = OAuthSubClass::signatureBase(oauthParams, url, operation);
signatureBase = OAuthSubClass::signatureBaseString(oauthParams, url, operation);
QCOMPARE(signatureBase, QByteArray("POST&https%3A%2F%2Fapi.twitter.com%2F1%2Fstatuses%2Fupdate.json"
"&include_entities%3Dtrue%26oauth_consumer_key%3Dxvz1evFS4wEEPTGEFPHBog"
"%26oauth_nonce%3DkYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg"
......@@ -245,7 +245,7 @@ void tst_QOAuth::createSignature()
"%26oauth_version%3D1.0%26status%3DHello%2520Ladies%2520%252B%2520Gentlemen%252C%2520a%2520signed%2520OAuth%2520request%2521"));
// Getting a signing key
signature = OAuthSubClass::sign(oauthParams, url, operation, consumerSecret, oauthTokenSecret);
signature = OAuthSubClass::signature(oauthParams, url, operation, consumerSecret, oauthTokenSecret);
QCOMPARE(signature, QByteArray("tnnArxj06cWHq44gCs1OSKk/jLY="));
}
......@@ -353,7 +353,7 @@ void tst_QOAuth::getToken()
o1.setClientCredentials(QOAuth1::Credential(client.key, client.secret));
o1.setToken(token);
o1.setRequestTokenUrl(url);
o1.setTemporaryCredentialsUrl(url);
reply.reset(o1.requestTokenCredentials(requestType, url, token));
QVERIFY(!reply.isNull());
connect(&o1, &QOAuth1::tokenChanged, [&tokenReceived](
......@@ -386,18 +386,18 @@ void tst_QOAuth::grant()
QOAuth1 o1(&networkAccessManager);
{
QSignalSpy spy(&o1, &QAbstractOAuth::requestTokenUrlChanged);
o1.setRequestTokenUrl(requestTokenUrl);
QSignalSpy spy(&o1, &QOAuth1::clientCredentialsChanged);
o1.setClientCredentials(QOAuth1::Credential(consumerKey, consumerSecret));
QCOMPARE(spy.count(), 1);
}
{
QSignalSpy spy(&o1, &QOAuth1::clientCredentialsChanged);
o1.setClientCredentials(QOAuth1::Credential(consumerKey, consumerSecret));
QSignalSpy spy(&o1, &QOAuth1::temporaryCredentialsUrlChanged);
o1.setTemporaryCredentialsUrl(requestTokenUrl);
QCOMPARE(spy.count(), 1);
}
{
QSignalSpy spy(&o1, &QAbstractOAuth::authorizationGrantUrlChanged);
o1.setAuthorizationGrantUrl(accessTokenUrl);
QSignalSpy spy(&o1, &QOAuth1::tokenCredentialsUrlChanged);
o1.setTokenCredentialsUrl(accessTokenUrl);
QCOMPARE(spy.count(), 1);
}
connect(&o1, &QAbstractOAuth::statusChanged, [&](QAbstractOAuth::Status status) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment