Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
qtoauth
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jesus Fernandez
qtoauth
Commits
41dd2c12
Commit
41dd2c12
authored
Aug 02, 2016
by
Jesus Fernandez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Comments and function rename
parent
e3fc27ca
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
55 additions
and
40 deletions
+55
-40
QtOAuth/private/qabstractoauth_p.h
QtOAuth/private/qabstractoauth_p.h
+1
-0
QtOAuth/private/qoauth1_p.h
QtOAuth/private/qoauth1_p.h
+0
-1
QtOAuth/private/qoauth2authorizationcodeflow_p.h
QtOAuth/private/qoauth2authorizationcodeflow_p.h
+3
-3
QtOAuth/private/qoauthhttpserverreplyhandler_p.h
QtOAuth/private/qoauthhttpserverreplyhandler_p.h
+2
-2
QtOAuth/qabstractoauth.cpp
QtOAuth/qabstractoauth.cpp
+7
-0
QtOAuth/qabstractoauth.h
QtOAuth/qabstractoauth.h
+3
-2
QtOAuth/qoauth1.cpp
QtOAuth/qoauth1.cpp
+4
-9
QtOAuth/qoauth2authorizationcodeflow.cpp
QtOAuth/qoauth2authorizationcodeflow.cpp
+22
-13
QtOAuth/qoauth2authorizationcodeflow.h
QtOAuth/qoauth2authorizationcodeflow.h
+2
-0
QtOAuth/qoauth2implicitgrantflow.cpp
QtOAuth/qoauth2implicitgrantflow.cpp
+1
-1
QtOAuth/qoauthhttpserverreplyhandler.cpp
QtOAuth/qoauthhttpserverreplyhandler.cpp
+5
-5
examples/googlecalendar/main.qml
examples/googlecalendar/main.qml
+2
-1
examples/qtgcal/main.cpp
examples/qtgcal/main.cpp
+1
-1
examples/redditclient/redditwrapper.cpp
examples/redditclient/redditwrapper.cpp
+1
-1
examples/twittertimeline/twitter.cpp
examples/twittertimeline/twitter.cpp
+1
-1
No files found.
QtOAuth/private/qabstractoauth_p.h
View file @
41dd2c12
...
@@ -80,6 +80,7 @@ public:
...
@@ -80,6 +80,7 @@ public:
QNetworkAccessManager
*
networkAccessManager
();
QNetworkAccessManager
*
networkAccessManager
();
void
setStatus
(
QAbstractOAuth
::
Status
status
);
void
setStatus
(
QAbstractOAuth
::
Status
status
);
// Resource Owner Authorization: https://tools.ietf.org/html/rfc5849#section-2.2
QUrl
authorizationUrl
;
QUrl
authorizationUrl
;
QVariantMap
extraTokens
;
QVariantMap
extraTokens
;
QAbstractOAuth
::
Status
status
=
QAbstractOAuth
::
Status
::
NotAuthenticated
;
QAbstractOAuth
::
Status
status
=
QAbstractOAuth
::
Status
::
NotAuthenticated
;
...
...
QtOAuth/private/qoauth1_p.h
View file @
41dd2c12
...
@@ -83,7 +83,6 @@ public:
...
@@ -83,7 +83,6 @@ public:
// private slots
// private slots
void
_q_onTokenRequestFinished
();
void
_q_onTokenRequestFinished
();
void
_q_onTokenRequestError
(
QNetworkReply
::
NetworkError
error
);
void
_q_onTokenRequestError
(
QNetworkReply
::
NetworkError
error
);
void
_q_onTokenExchangeError
(
QNetworkReply
::
NetworkError
error
);
void
_q_requestAuthorizationGrantAnswer
();
void
_q_requestAuthorizationGrantAnswer
();
void
_q_tokensReceived
(
const
QVariantMap
&
tokens
);
void
_q_tokensReceived
(
const
QVariantMap
&
tokens
);
...
...
QtOAuth/private/qoauth2authorizationcodeflow_p.h
View file @
41dd2c12
...
@@ -69,9 +69,9 @@ class OAUTH_EXPORT QOAuth2AuthorizationCodeFlowPrivate : public QAbstractOAuth2P
...
@@ -69,9 +69,9 @@ class OAUTH_EXPORT QOAuth2AuthorizationCodeFlowPrivate : public QAbstractOAuth2P
public:
public:
QOAuth2AuthorizationCodeFlowPrivate
(
QNetworkAccessManager
*
manager
=
nullptr
);
QOAuth2AuthorizationCodeFlowPrivate
(
QNetworkAccessManager
*
manager
=
nullptr
);
void
handleCallback
(
const
QVariantMap
&
data
);
void
_q_
handleCallback
(
const
QVariantMap
&
data
);
void
accessTokenRequestFinished
(
QNetworkReply
*
reply
);
void
_q_
accessTokenRequestFinished
(
QNetworkReply
*
reply
);
void
authenticate
(
QNetworkReply
*
reply
,
QAuthenticator
*
authenticator
);
void
_q_
authenticate
(
QNetworkReply
*
reply
,
QAuthenticator
*
authenticator
);
QUrl
accessTokenUrl
;
QUrl
accessTokenUrl
;
QString
tokenType
;
QString
tokenType
;
...
...
QtOAuth/private/qoauthhttpserverreplyhandler_p.h
View file @
41dd2c12
...
@@ -73,8 +73,8 @@ public:
...
@@ -73,8 +73,8 @@ public:
QString
text
;
QString
text
;
private:
private:
void
onC
lientConnected
();
void
_q_c
lientConnected
();
void
answerClient
();
void
_q_
answerClient
();
};
};
QT_END_NAMESPACE
QT_END_NAMESPACE
...
...
QtOAuth/qabstractoauth.cpp
View file @
41dd2c12
...
@@ -186,6 +186,13 @@ QString QAbstractOAuth::callback() const
...
@@ -186,6 +186,13 @@ QString QAbstractOAuth::callback() const
:
d
->
defaultReplyHandler
->
callback
();
:
d
->
defaultReplyHandler
->
callback
();
}
}
void
QAbstractOAuth
::
resourceOwnerAuthorization
(
const
QUrl
&
url
,
const
QVariantMap
&
parameters
)
{
QUrl
u
=
url
;
u
.
setQuery
(
QAbstractOAuthPrivate
::
createQuery
(
parameters
));
Q_EMIT
authorizeWithBrowser
(
u
);
}
QT_END_NAMESPACE
QT_END_NAMESPACE
#endif // QT_NO_HTTP
#endif // QT_NO_HTTP
QtOAuth/qabstractoauth.h
View file @
41dd2c12
...
@@ -116,7 +116,6 @@ public:
...
@@ -116,7 +116,6 @@ public:
Status
status
()
const
;
Status
status
()
const
;
// Resource Owner Authorization: https://tools.ietf.org/html/rfc5849#section-2.2
QUrl
authorizationUrl
()
const
;
QUrl
authorizationUrl
()
const
;
void
setAuthorizationUrl
(
const
QUrl
&
url
);
void
setAuthorizationUrl
(
const
QUrl
&
url
);
...
@@ -148,7 +147,7 @@ Q_SIGNALS:
...
@@ -148,7 +147,7 @@ Q_SIGNALS:
void
extraTokensChanged
(
const
QVariantMap
&
tokens
);
void
extraTokensChanged
(
const
QVariantMap
&
tokens
);
void
requestFailed
(
const
Error
error
);
void
requestFailed
(
const
Error
error
);
void
authoriz
ationRequested
(
const
QUrl
&
url
);
void
authoriz
eWithBrowser
(
const
QUrl
&
url
);
void
granted
();
void
granted
();
void
finished
(
QNetworkReply
*
reply
);
void
finished
(
QNetworkReply
*
reply
);
void
replyDataReceived
(
const
QByteArray
&
data
);
void
replyDataReceived
(
const
QByteArray
&
data
);
...
@@ -160,6 +159,8 @@ protected:
...
@@ -160,6 +159,8 @@ protected:
QString
callback
()
const
;
QString
callback
()
const
;
virtual
void
resourceOwnerAuthorization
(
const
QUrl
&
url
,
const
QVariantMap
&
parameters
);
private:
private:
Q_DISABLE_COPY
(
QAbstractOAuth
)
Q_DISABLE_COPY
(
QAbstractOAuth
)
Q_DECLARE_PRIVATE
(
QAbstractOAuth
)
Q_DECLARE_PRIVATE
(
QAbstractOAuth
)
...
...
QtOAuth/qoauth1.cpp
View file @
41dd2c12
...
@@ -87,12 +87,6 @@ void QOAuth1Private::_q_onTokenRequestError(QNetworkReply::NetworkError error)
...
@@ -87,12 +87,6 @@ void QOAuth1Private::_q_onTokenRequestError(QNetworkReply::NetworkError error)
Q_EMIT
q
->
requestFailed
(
QAbstractOAuth
::
Error
::
NetworkError
);
Q_EMIT
q
->
requestFailed
(
QAbstractOAuth
::
Error
::
NetworkError
);
}
}
void
QOAuth1Private
::
_q_onTokenExchangeError
(
QNetworkReply
::
NetworkError
)
{
Q_Q
(
QOAuth1
);
Q_EMIT
q
->
requestFailed
(
QAbstractOAuth
::
Error
::
NetworkError
);
}
void
QOAuth1Private
::
_q_requestAuthorizationGrantAnswer
()
void
QOAuth1Private
::
_q_requestAuthorizationGrantAnswer
()
{
{
Q_Q
(
QOAuth1
);
Q_Q
(
QOAuth1
);
...
@@ -504,6 +498,7 @@ QNetworkReply *QOAuth1::requestTemporaryCredentials(QNetworkAccessManager::Opera
...
@@ -504,6 +498,7 @@ QNetworkReply *QOAuth1::requestTemporaryCredentials(QNetworkAccessManager::Opera
const
QUrl
&
url
,
const
QUrl
&
url
,
const
QVariantMap
&
parameters
)
const
QVariantMap
&
parameters
)
{
{
// https://tools.ietf.org/html/rfc5849#section-2.1
Q_D
(
QOAuth1
);
Q_D
(
QOAuth1
);
if
(
Q_UNLIKELY
(
!
d
->
networkAccessManager
()))
{
if
(
Q_UNLIKELY
(
!
d
->
networkAccessManager
()))
{
qCritical
(
"QNetworkAccessManager not available"
);
qCritical
(
"QNetworkAccessManager not available"
);
...
@@ -653,6 +648,7 @@ QByteArray QOAuth1::signatureBaseString(const QVariantMap ¶meters,
...
@@ -653,6 +648,7 @@ QByteArray QOAuth1::signatureBaseString(const QVariantMap ¶meters,
const
QUrl
&
url
,
const
QUrl
&
url
,
QNetworkAccessManager
::
Operation
op
)
QNetworkAccessManager
::
Operation
op
)
{
{
// https://tools.ietf.org/html/rfc5849#section-3.4.1
QByteArray
base
;
QByteArray
base
;
base
.
append
(
QOAuth1Private
::
operationName
(
op
).
toUtf8
()
+
"&"
);
base
.
append
(
QOAuth1Private
::
operationName
(
op
).
toUtf8
()
+
"&"
);
...
@@ -733,9 +729,8 @@ void QOAuth1::grant()
...
@@ -733,9 +729,8 @@ void QOAuth1::grant()
if
(
d
->
modifyParametersFunction
)
if
(
d
->
modifyParametersFunction
)
d
->
modifyParametersFunction
(
Stage
::
RequestingAuthorization
,
&
parameters
);
d
->
modifyParametersFunction
(
Stage
::
RequestingAuthorization
,
&
parameters
);
QUrl
url
=
d
->
authorizationUrl
;
// https://tools.ietf.org/html/rfc5849#section-2.2
url
.
setQuery
(
QAbstractOAuthPrivate
::
createQuery
(
parameters
));
resourceOwnerAuthorization
(
d
->
authorizationUrl
,
parameters
);
Q_EMIT
authorizationRequested
(
url
);
}
}
else
{
else
{
// try upgrading token without verifier
// try upgrading token without verifier
...
...
QtOAuth/qoauth2authorizationcodeflow.cpp
View file @
41dd2c12
...
@@ -59,7 +59,7 @@ QOAuth2AuthorizationCodeFlowPrivate::QOAuth2AuthorizationCodeFlowPrivate(
...
@@ -59,7 +59,7 @@ QOAuth2AuthorizationCodeFlowPrivate::QOAuth2AuthorizationCodeFlowPrivate(
QNetworkAccessManager
*
manager
)
:
QAbstractOAuth2Private
(
manager
)
QNetworkAccessManager
*
manager
)
:
QAbstractOAuth2Private
(
manager
)
{}
{}
void
QOAuth2AuthorizationCodeFlowPrivate
::
handleCallback
(
const
QVariantMap
&
data
)
void
QOAuth2AuthorizationCodeFlowPrivate
::
_q_
handleCallback
(
const
QVariantMap
&
data
)
{
{
Q_Q
(
QOAuth2AuthorizationCodeFlow
);
Q_Q
(
QOAuth2AuthorizationCodeFlow
);
typedef
QAbstractOAuth2Private
::
OAuth2KeyString
Key
;
typedef
QAbstractOAuth2Private
::
OAuth2KeyString
Key
;
...
@@ -99,7 +99,7 @@ void QOAuth2AuthorizationCodeFlowPrivate::handleCallback(const QVariantMap &data
...
@@ -99,7 +99,7 @@ void QOAuth2AuthorizationCodeFlowPrivate::handleCallback(const QVariantMap &data
q
->
requestAccessToken
(
code
);
q
->
requestAccessToken
(
code
);
}
}
void
QOAuth2AuthorizationCodeFlowPrivate
::
accessTokenRequestFinished
(
QNetworkReply
*
reply
)
void
QOAuth2AuthorizationCodeFlowPrivate
::
_q_
accessTokenRequestFinished
(
QNetworkReply
*
reply
)
{
{
Q_Q
(
QOAuth2AuthorizationCodeFlow
);
Q_Q
(
QOAuth2AuthorizationCodeFlow
);
typedef
QAbstractOAuth2Private
::
OAuth2KeyString
Key
;
typedef
QAbstractOAuth2Private
::
OAuth2KeyString
Key
;
...
@@ -146,7 +146,7 @@ void QOAuth2AuthorizationCodeFlowPrivate::accessTokenRequestFinished(QNetworkRep
...
@@ -146,7 +146,7 @@ void QOAuth2AuthorizationCodeFlowPrivate::accessTokenRequestFinished(QNetworkRep
setStatus
(
QAbstractOAuth
::
Status
::
Granted
);
setStatus
(
QAbstractOAuth
::
Status
::
Granted
);
}
}
void
QOAuth2AuthorizationCodeFlowPrivate
::
authenticate
(
QNetworkReply
*
reply
,
void
QOAuth2AuthorizationCodeFlowPrivate
::
_q_
authenticate
(
QNetworkReply
*
reply
,
QAuthenticator
*
authenticator
)
QAuthenticator
*
authenticator
)
{
{
if
(
reply
==
currentReply
){
if
(
reply
==
currentReply
){
...
@@ -234,10 +234,7 @@ void QOAuth2AuthorizationCodeFlow::grant()
...
@@ -234,10 +234,7 @@ void QOAuth2AuthorizationCodeFlow::grant()
return
;
return
;
}
}
const
QUrl
url
=
buildAuthenticateUrl
();
resourceOwnerAuthorization
(
d
->
authorizationUrl
);
QObjectPrivate
::
connect
(
this
,
&
QOAuth2AuthorizationCodeFlow
::
authorizationCallbackReceived
,
d
,
&
QOAuth2AuthorizationCodeFlowPrivate
::
handleCallback
);
Q_EMIT
authorizationRequested
(
url
);
}
}
void
QOAuth2AuthorizationCodeFlow
::
refreshAccessToken
()
void
QOAuth2AuthorizationCodeFlow
::
refreshAccessToken
()
...
@@ -266,10 +263,10 @@ void QOAuth2AuthorizationCodeFlow::refreshAccessToken()
...
@@ -266,10 +263,10 @@ void QOAuth2AuthorizationCodeFlow::refreshAccessToken()
d
->
currentReply
=
d
->
networkAccessManager
()
->
post
(
request
,
data
.
toUtf8
());
d
->
currentReply
=
d
->
networkAccessManager
()
->
post
(
request
,
data
.
toUtf8
());
QObjectPrivate
::
connect
(
d
->
networkAccessManager
(),
&
QNetworkAccessManager
::
finished
,
QObjectPrivate
::
connect
(
d
->
networkAccessManager
(),
&
QNetworkAccessManager
::
finished
,
d
,
&
QOAuth2AuthorizationCodeFlowPrivate
::
accessTokenRequestFinished
);
d
,
&
QOAuth2AuthorizationCodeFlowPrivate
::
_q_
accessTokenRequestFinished
);
QObjectPrivate
::
connect
(
d
->
networkAccessManager
(),
QObjectPrivate
::
connect
(
d
->
networkAccessManager
(),
&
QNetworkAccessManager
::
authenticationRequired
,
&
QNetworkAccessManager
::
authenticationRequired
,
d
,
&
QOAuth2AuthorizationCodeFlowPrivate
::
authenticate
,
d
,
&
QOAuth2AuthorizationCodeFlowPrivate
::
_q_
authenticate
,
Qt
::
UniqueConnection
);
Qt
::
UniqueConnection
);
}
}
...
@@ -294,9 +291,9 @@ QUrl QOAuth2AuthorizationCodeFlow::buildAuthenticateUrl(const QVariantMap ¶m
...
@@ -294,9 +291,9 @@ QUrl QOAuth2AuthorizationCodeFlow::buildAuthenticateUrl(const QVariantMap ¶m
d
->
modifyParametersFunction
(
Stage
::
RequestingAuthorization
,
&
p
);
d
->
modifyParametersFunction
(
Stage
::
RequestingAuthorization
,
&
p
);
url
.
setQuery
(
d
->
createQuery
(
p
));
url
.
setQuery
(
d
->
createQuery
(
p
));
connect
(
d
->
replyHandler
.
data
(),
&
QAbstractOAuthReplyHandler
::
callbackReceived
,
this
,
connect
(
d
->
replyHandler
.
data
(),
&
QAbstractOAuthReplyHandler
::
callbackReceived
,
this
,
&
QOAuth2AuthorizationCodeFlow
::
authorizationCallbackReceived
);
&
QOAuth2AuthorizationCodeFlow
::
authorizationCallbackReceived
,
Qt
::
UniqueConnection
);
setStatus
(
QAbstractOAuth
::
Status
::
NotAuthenticated
);
setStatus
(
QAbstractOAuth
::
Status
::
NotAuthenticated
);
qDebug
(
)
<<
url
;
qDebug
(
"QOAuth2AuthorizationCodeFlow::buildAuthenticateUrl: %s"
,
qPrintable
(
url
.
toString
()))
;
return
url
;
return
url
;
}
}
...
@@ -323,11 +320,23 @@ void QOAuth2AuthorizationCodeFlow::requestAccessToken(const QString &code)
...
@@ -323,11 +320,23 @@ void QOAuth2AuthorizationCodeFlow::requestAccessToken(const QString &code)
const
QString
data
=
query
.
toString
(
QUrl
::
FullyEncoded
);
const
QString
data
=
query
.
toString
(
QUrl
::
FullyEncoded
);
d
->
currentReply
=
d
->
networkAccessManager
()
->
post
(
request
,
data
.
toUtf8
());
d
->
currentReply
=
d
->
networkAccessManager
()
->
post
(
request
,
data
.
toUtf8
());
QObjectPrivate
::
connect
(
d
->
networkAccessManager
(),
&
QNetworkAccessManager
::
finished
,
QObjectPrivate
::
connect
(
d
->
networkAccessManager
(),
&
QNetworkAccessManager
::
finished
,
d
,
&
QOAuth2AuthorizationCodeFlowPrivate
::
accessTokenRequestFinished
);
d
,
&
QOAuth2AuthorizationCodeFlowPrivate
::
_q_
accessTokenRequestFinished
);
QObjectPrivate
::
connect
(
d
->
networkAccessManager
(),
QObjectPrivate
::
connect
(
d
->
networkAccessManager
(),
&
QNetworkAccessManager
::
authenticationRequired
,
&
QNetworkAccessManager
::
authenticationRequired
,
d
,
&
QOAuth2AuthorizationCodeFlowPrivate
::
authenticate
,
d
,
&
QOAuth2AuthorizationCodeFlowPrivate
::
_q_authenticate
,
Qt
::
UniqueConnection
);
}
void
QOAuth2AuthorizationCodeFlow
::
resourceOwnerAuthorization
(
const
QUrl
&
url
,
const
QVariantMap
&
parameters
)
{
Q_D
(
QOAuth2AuthorizationCodeFlow
);
Q_ASSERT
(
url
==
d
->
authorizationUrl
);
const
QUrl
u
=
buildAuthenticateUrl
(
parameters
);
QObjectPrivate
::
connect
(
this
,
&
QOAuth2AuthorizationCodeFlow
::
authorizationCallbackReceived
,
d
,
&
QOAuth2AuthorizationCodeFlowPrivate
::
_q_handleCallback
,
Qt
::
UniqueConnection
);
Qt
::
UniqueConnection
);
Q_EMIT
authorizeWithBrowser
(
u
);
}
}
QT_END_NAMESPACE
QT_END_NAMESPACE
...
...
QtOAuth/qoauth2authorizationcodeflow.h
View file @
41dd2c12
...
@@ -93,6 +93,8 @@ public Q_SLOTS:
...
@@ -93,6 +93,8 @@ public Q_SLOTS:
protected:
protected:
QUrl
buildAuthenticateUrl
(
const
QVariantMap
&
parameters
=
QVariantMap
());
QUrl
buildAuthenticateUrl
(
const
QVariantMap
&
parameters
=
QVariantMap
());
void
requestAccessToken
(
const
QString
&
code
);
void
requestAccessToken
(
const
QString
&
code
);
virtual
void
resourceOwnerAuthorization
(
const
QUrl
&
url
,
const
QVariantMap
&
parameters
=
QVariantMap
())
override
;
Q_SIGNALS:
Q_SIGNALS:
void
accessTokenUrlChanged
(
const
QUrl
&
accessTokenUrl
);
void
accessTokenUrlChanged
(
const
QUrl
&
accessTokenUrl
);
...
...
QtOAuth/qoauth2implicitgrantflow.cpp
View file @
41dd2c12
...
@@ -90,7 +90,7 @@ void QOAuth2ImplicitGrantFlow::grant()
...
@@ -90,7 +90,7 @@ void QOAuth2ImplicitGrantFlow::grant()
{
{
const
QString
state
=
QAbstractOAuth2Private
::
generateRandomState
();
const
QString
state
=
QAbstractOAuth2Private
::
generateRandomState
();
const
QUrl
url
=
authorizationRequestUrl
(
state
);
const
QUrl
url
=
authorizationRequestUrl
(
state
);
Q_EMIT
authoriz
ationRequested
(
url
);
Q_EMIT
authoriz
eWithBrowser
(
url
);
}
}
QUrl
QOAuth2ImplicitGrantFlow
::
authorizationRequestUrl
(
const
QString
&
state
)
const
QUrl
QOAuth2ImplicitGrantFlow
::
authorizationRequestUrl
(
const
QString
&
state
)
const
...
...
QtOAuth/qoauthhttpserverreplyhandler.cpp
View file @
41dd2c12
...
@@ -64,16 +64,16 @@ QOAuthHttpServerReplyHandlerPrivate::QOAuthHttpServerReplyHandlerPrivate(quint16
...
@@ -64,16 +64,16 @@ QOAuthHttpServerReplyHandlerPrivate::QOAuthHttpServerReplyHandlerPrivate(quint16
QOAuthHttpServerReplyHandlerPrivate
::~
QOAuthHttpServerReplyHandlerPrivate
()
QOAuthHttpServerReplyHandlerPrivate
::~
QOAuthHttpServerReplyHandlerPrivate
()
{}
{}
void
QOAuthHttpServerReplyHandlerPrivate
::
onC
lientConnected
()
void
QOAuthHttpServerReplyHandlerPrivate
::
_q_c
lientConnected
()
{
{
QTcpSocket
*
socket
=
httpServer
.
nextPendingConnection
();
QTcpSocket
*
socket
=
httpServer
.
nextPendingConnection
();
QObject
::
connect
(
socket
,
&
QTcpSocket
::
disconnected
,
socket
,
&
QTcpSocket
::
deleteLater
);
QObject
::
connect
(
socket
,
&
QTcpSocket
::
disconnected
,
socket
,
&
QTcpSocket
::
deleteLater
);
connect
(
socket
,
&
QTcpSocket
::
readyRead
,
connect
(
socket
,
&
QTcpSocket
::
readyRead
,
this
,
&
QOAuthHttpServerReplyHandlerPrivate
::
answerClient
);
this
,
&
QOAuthHttpServerReplyHandlerPrivate
::
_q_
answerClient
);
}
}
void
QOAuthHttpServerReplyHandlerPrivate
::
answerClient
()
void
QOAuthHttpServerReplyHandlerPrivate
::
_q_
answerClient
()
{
{
Q_Q
(
QOAuthHttpServerReplyHandler
);
Q_Q
(
QOAuthHttpServerReplyHandler
);
QTcpSocket
*
socket
=
static_cast
<
QTcpSocket
*>
(
currentSender
->
sender
);
QTcpSocket
*
socket
=
static_cast
<
QTcpSocket
*>
(
currentSender
->
sender
);
...
@@ -108,7 +108,7 @@ QOAuthHttpServerReplyHandler::QOAuthHttpServerReplyHandler(QObject *parent)
...
@@ -108,7 +108,7 @@ QOAuthHttpServerReplyHandler::QOAuthHttpServerReplyHandler(QObject *parent)
{
{
Q_D
(
QOAuthHttpServerReplyHandler
);
Q_D
(
QOAuthHttpServerReplyHandler
);
d
->
connect
(
&
d
->
httpServer
,
&
QTcpServer
::
newConnection
,
d
->
connect
(
&
d
->
httpServer
,
&
QTcpServer
::
newConnection
,
d
,
&
QOAuthHttpServerReplyHandlerPrivate
::
onC
lientConnected
);
d
,
&
QOAuthHttpServerReplyHandlerPrivate
::
_q_c
lientConnected
);
}
}
QOAuthHttpServerReplyHandler
::
QOAuthHttpServerReplyHandler
(
quint16
port
,
QObject
*
parent
)
QOAuthHttpServerReplyHandler
::
QOAuthHttpServerReplyHandler
(
quint16
port
,
QObject
*
parent
)
...
@@ -116,7 +116,7 @@ QOAuthHttpServerReplyHandler::QOAuthHttpServerReplyHandler(quint16 port, QObject
...
@@ -116,7 +116,7 @@ QOAuthHttpServerReplyHandler::QOAuthHttpServerReplyHandler(quint16 port, QObject
{
{
Q_D
(
QOAuthHttpServerReplyHandler
);
Q_D
(
QOAuthHttpServerReplyHandler
);
d
->
connect
(
&
d
->
httpServer
,
&
QTcpServer
::
newConnection
,
d
->
connect
(
&
d
->
httpServer
,
&
QTcpServer
::
newConnection
,
d
,
&
QOAuthHttpServerReplyHandlerPrivate
::
onC
lientConnected
);
d
,
&
QOAuthHttpServerReplyHandlerPrivate
::
_q_c
lientConnected
);
}
}
QOAuthHttpServerReplyHandler
::~
QOAuthHttpServerReplyHandler
()
QOAuthHttpServerReplyHandler
::~
QOAuthHttpServerReplyHandler
()
...
...
examples/googlecalendar/main.qml
View file @
41dd2c12
...
@@ -124,8 +124,9 @@ ApplicationWindow {
...
@@ -124,8 +124,9 @@ ApplicationWindow {
scope
:
"
https://www.googleapis.com/auth/calendar.readonly
"
scope
:
"
https://www.googleapis.com/auth/calendar.readonly
"
port
:
1965
port
:
1965
onAuthoriz
ationRequested
:
{
onAuthoriz
eWithBrowser
:
{
webView
.
url
=
url
;
webView
.
url
=
url
;
console
.
log
(
"
Url:
"
+
url
);
webView
.
visible
=
true
;
webView
.
visible
=
true
;
}
}
Component.onCompleted
:
grant
();
Component.onCompleted
:
grant
();
...
...
examples/qtgcal/main.cpp
View file @
41dd2c12
...
@@ -111,7 +111,7 @@ int main(int argc, char **argv)
...
@@ -111,7 +111,7 @@ int main(int argc, char **argv)
parameters
->
insert
(
"grant_type"
,
"authorization_code"
);
parameters
->
insert
(
"grant_type"
,
"authorization_code"
);
}
}
});
});
QObject
::
connect
(
&
o2
,
&
QOAuth2AuthorizationCodeFlow
::
authoriz
ationRequested
,
QObject
::
connect
(
&
o2
,
&
QOAuth2AuthorizationCodeFlow
::
authoriz
eWithBrowser
,
&
QDesktopServices
::
openUrl
);
&
QDesktopServices
::
openUrl
);
QNetworkReply
*
reply
=
nullptr
;
QNetworkReply
*
reply
=
nullptr
;
...
...
examples/redditclient/redditwrapper.cpp
View file @
41dd2c12
...
@@ -65,7 +65,7 @@ RedditWrapper::RedditWrapper(QObject *parent)
...
@@ -65,7 +65,7 @@ RedditWrapper::RedditWrapper(QObject *parent)
if
(
stage
==
QAbstractOAuth
::
Stage
::
RequestingAuthorization
&&
isPermanent
())
if
(
stage
==
QAbstractOAuth
::
Stage
::
RequestingAuthorization
&&
isPermanent
())
parameters
->
insert
(
"duration"
,
"permanent"
);
parameters
->
insert
(
"duration"
,
"permanent"
);
});
});
connect
(
&
oauth2
,
&
QOAuth2AuthorizationCodeFlow
::
authoriz
ationRequested
,
connect
(
&
oauth2
,
&
QOAuth2AuthorizationCodeFlow
::
authoriz
eWithBrowser
,
&
QDesktopServices
::
openUrl
);
&
QDesktopServices
::
openUrl
);
}
}
...
...
examples/twittertimeline/twitter.cpp
View file @
41dd2c12
...
@@ -52,7 +52,7 @@ Twitter::Twitter(QObject *parent) :
...
@@ -52,7 +52,7 @@ Twitter::Twitter(QObject *parent) :
setAuthorizationUrl
(
QUrl
(
"https://api.twitter.com/oauth/authenticate"
));
setAuthorizationUrl
(
QUrl
(
"https://api.twitter.com/oauth/authenticate"
));
setTokenCredentialsUrl
(
QUrl
(
"https://api.twitter.com/oauth/access_token"
));
setTokenCredentialsUrl
(
QUrl
(
"https://api.twitter.com/oauth/access_token"
));
connect
(
this
,
&
QAbstractOAuth
::
authoriz
ationRequested
,
[
&
](
QUrl
url
)
{
connect
(
this
,
&
QAbstractOAuth
::
authoriz
eWithBrowser
,
[
&
](
QUrl
url
)
{
QUrlQuery
query
(
url
);
QUrlQuery
query
(
url
);
query
.
addQueryItem
(
"force_login"
,
"true"
);
// Forces the user to enter their credentials to
query
.
addQueryItem
(
"force_login"
,
"true"
);
// Forces the user to enter their credentials to
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment