Merge pull request #3 from slegge/patch-authurl-1
Split user authorization into two parts
This commit is contained in:
commit
11f5bff9d9
2 changed files with 21 additions and 7 deletions
|
@ -441,19 +441,19 @@ void KQOAuthManager::getOauth2UserAuthorization(QUrl authorizationEndpoint, QStr
|
|||
navigator_invoke(openWebPageUrl.toString().toStdString().c_str(),0);
|
||||
}
|
||||
|
||||
void KQOAuthManager::getUserAuthorization(QUrl authorizationEndpoint) {
|
||||
QUrl KQOAuthManager::getUserAuthorizationUrl(QUrl authorizationEndpoint) {
|
||||
Q_D(KQOAuthManager);
|
||||
|
||||
if (!d->hasTemporaryToken) {
|
||||
qWarning() << "No temporary tokens retreieved. Cannot get user authorization.";
|
||||
d->error = KQOAuthManager::RequestUnauthorized;
|
||||
return;
|
||||
return QUrl();
|
||||
}
|
||||
|
||||
if (!authorizationEndpoint.isValid()) {
|
||||
qWarning() << "Authorization endpoint not valid. Cannot proceed.";
|
||||
d->error = KQOAuthManager::RequestEndpointError;
|
||||
return;
|
||||
return QUrl();
|
||||
}
|
||||
|
||||
d->error = KQOAuthManager::NoError;
|
||||
|
@ -462,11 +462,19 @@ void KQOAuthManager::getUserAuthorization(QUrl authorizationEndpoint) {
|
|||
QUrl openWebPageUrl(authorizationEndpoint.toString(), QUrl::StrictMode);
|
||||
openWebPageUrl.addQueryItem(tokenParam.first, tokenParam.second);
|
||||
|
||||
qDebug() << openWebPageUrl.toString();
|
||||
return openWebPageUrl;
|
||||
}
|
||||
|
||||
void KQOAuthManager::getUserAuthorization(QUrl authorizationEndpoint) {
|
||||
QUrl openWebPageUrl = getUserAuthorizationUrl(authorizationEndpoint);
|
||||
|
||||
if(!openWebPageUrl.isEmpty()) {
|
||||
// Open the user's default browser to the resource authorization page provided
|
||||
// by the service.
|
||||
|
||||
qDebug() << openWebPageUrl.toString();
|
||||
navigator_invoke(openWebPageUrl.toString().toStdString().c_str(),0);
|
||||
}
|
||||
}
|
||||
|
||||
void KQOAuthManager::getUserAccessTokens(QUrl accessTokenEndpoint) {
|
||||
|
|
|
@ -106,6 +106,12 @@ public:
|
|||
*/
|
||||
void setSuccessHtmlFile(QString filePath);
|
||||
|
||||
/**
|
||||
* This is a convenience API for authorizing the user.
|
||||
* The call will verify that a temporary token was received and return the url that the user needs to
|
||||
* use to authorize the app, it will not open the user's default browser.
|
||||
*/
|
||||
QUrl getUserAuthorizationUrl(QUrl authorizationEndpoint);
|
||||
/**
|
||||
* This is a convenience API for authorizing the user.
|
||||
* The call will open the user's default browser, setup a local HTTP server and parse the reply from the
|
||||
|
|
Loading…
Reference in a new issue