diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b7fb39e --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +build/* +*.pro.user* +ccross-fuse/* +ccross-fuse-worker/* +.directory diff --git a/CHANGES.MD b/CHANGES.MD index 39b61b4..24067a1 100644 --- a/CHANGES.MD +++ b/CHANGES.MD @@ -1,5 +1,8 @@ ## Change log: +### v1.4.7 +- fix GoogleDrive auth problem (**WARNING!! This version has a new Google API Key, and this means that a previous GoogleDrive auth will be broken**) + ### v1.4.6 - fix console log printing and segfaults caused by it ### v1.4.5 diff --git a/README.MD b/README.MD index 9654495..10f3b77 100644 --- a/README.MD +++ b/README.MD @@ -1,11 +1,17 @@ # The CloudCross Project -## Current version: 1.4.6 -Release date: **2020-01-16** +## Current version: 1.4.7 +Release date: **2020-11-28** Author: **Kamensky Vladimir** +*** + +**WARNING!! This version has a new Google API Key, and this means that a previous GoogleDrive auth will be broken** + +*** + The CloudCross is a open source project for a synchronization between your devices and various cloud storages. This software is a cross-platform and could be run on Linux, Windows and Mac OS. diff --git a/build/debug/ccross-app/ccross b/build/debug/ccross-app/ccross deleted file mode 100755 index d7f12fe..0000000 Binary files a/build/debug/ccross-app/ccross and /dev/null differ diff --git a/build/debug/ccross-curl-executor/ccross-curl b/build/debug/ccross-curl-executor/ccross-curl deleted file mode 100755 index 5ee1ccb..0000000 Binary files a/build/debug/ccross-curl-executor/ccross-curl and /dev/null differ diff --git a/ccross-app/include/mscloudprovider.h b/ccross-app/include/mscloudprovider.h index e1a8b45..b37e0f9 100644 --- a/ccross-app/include/mscloudprovider.h +++ b/ccross-app/include/mscloudprovider.h @@ -77,6 +77,8 @@ class MSCloudProvider : public QObject public: + int skipRedirectsCount =0; + MSNetworkProxy* proxyServer; QString currentPath;// directory where program was run diff --git a/ccross-app/main.cpp b/ccross-app/main.cpp index 63bc639..49e0300 100644 --- a/ccross-app/main.cpp +++ b/ccross-app/main.cpp @@ -66,7 +66,7 @@ #define APP_MAJOR_VERSION 1 #define APP_MINOR_VERSION 4 -#define APP_BUILD_NUMBER "6" +#define APP_BUILD_NUMBER "7" #define CCROSS_HOME_DIR ".ccross" #define CCROSS_CONFIG_FILE "ccross.conf" diff --git a/ccross-app/src/GoogleDrive/msgoogledrive.cpp b/ccross-app/src/GoogleDrive/msgoogledrive.cpp index 428c3d2..80e41cb 100644 --- a/ccross-app/src/GoogleDrive/msgoogledrive.cpp +++ b/ccross-app/src/GoogleDrive/msgoogledrive.cpp @@ -63,30 +63,39 @@ bool MSGoogleDrive::auth(){ connect(this,SIGNAL(oAuthError(QString,MSCloudProvider*)),this,SLOT(onAuthFinished(QString, MSCloudProvider*))); - MSHttpRequest* req=new MSHttpRequest(this->proxyServer); +// MSHttpRequest* req=new MSHttpRequest(this->proxyServer); - req->setRequestUrl(QStringLiteral("https://accounts.google.com/o/oauth2/v2/auth")); - req->setMethod(QStringLiteral("get")); +// req->setRequestUrl(QStringLiteral("https://accounts.google.com/o/oauth2/v2/auth")); +// req->setMethod(QStringLiteral("get")); // req->addQueryItem(QStringLiteral("scope"), QStringLiteral("https://www.googleapis.com/auth/drive+https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://docs.google.com/feeds/+https://docs.googleusercontent.com/+https://spreadsheets.google.com/feeds/")); - req->addQueryItem(QStringLiteral("scope"), QStringLiteral("https://www.googleapis.com/auth/drive")); - req->addQueryItem(QStringLiteral("redirect_uri"), QStringLiteral("http://127.0.0.1:1973")); - req->addQueryItem(QStringLiteral("response_type"), QStringLiteral("code")); - req->addQueryItem(QStringLiteral("client_id"), QStringLiteral("834415955748-oq0p2m5dro2bvh3bu0o5bp19ok3qrs3f.apps.googleusercontent.com")); - req->addQueryItem(QStringLiteral("access_type"), QStringLiteral("offline")); - req->addQueryItem(QStringLiteral("approval_prompt"), QStringLiteral("force")); - req->addQueryItem(QStringLiteral("state"), QStringLiteral("1")); +//// req->addQueryItem(QStringLiteral("scope"), QStringLiteral("https://www.googleapis.com/auth/drive")); +// req->addQueryItem(QStringLiteral("redirect_uri"), QStringLiteral("http://127.0.0.1:1973")); +// req->addQueryItem(QStringLiteral("response_type"), QStringLiteral("code")); +// req->addQueryItem(QStringLiteral("client_id"), QStringLiteral("251547413210-t1iem90k7hobv18fl2qtfbckic22lml3.apps.googleusercontent.com")); +//// req->addQueryItem(QStringLiteral("access_type"), QStringLiteral("offline")); +//// req->addQueryItem(QStringLiteral("approval_prompt"), QStringLiteral("force")); +//// req->addQueryItem(QStringLiteral("state"), QStringLiteral("1")); - req->exec(); +// req->exec(); - if(!req->replyOK()){ - req->printReplyError(); - delete(req); - this->providerAuthStatus=false; - return false; - } +// if(!req->replyOK()){ +// req->printReplyError(); +// delete(req); +// this->providerAuthStatus=false; +// return false; +// } + + QString r = "https://accounts.google.com/o/oauth2/v2/auth?"; + r.append("client_id=251547413210-t1iem90k7hobv18fl2qtfbckic22lml3.apps.googleusercontent.com&scope=https://www.googleapis.com/auth/drive+https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://docs.google.com/feeds/+https://docs.googleusercontent.com/+https://spreadsheets.google.com/feeds/&"); + r.append("redirect_uri=http%3a//127.0.0.1:1973&"); + r.append("response_type=code&"); + r.append("access_type=offline&"); + r.append("approval_prompt=force&state=1&"); +// r.append("client_id=251547413210-t1iem90k7hobv18fl2qtfbckic22lml3.apps.googleusercontent.com"); + this->skipRedirectsCount = 1; this->startListener(1973); // if(!this->testReplyBodyForError(req->readReplyText())){ @@ -96,17 +105,17 @@ bool MSGoogleDrive::auth(){ qInfo()<< QStringLiteral("-------------------------------------") ; - qInfo()<< tr("The CloudCross needs a follow permissions:"); - qInfo()<< tr(" - Full access to your GoogleDrive content (https://www.googleapis.com/auth/drive)")<replyURL(); + qInfo() << r; qInfo() ; ; - delete(req); +// delete(req); QEventLoop loop; connect(this, SIGNAL(providerAuthComplete()), &loop, SLOT(quit())); @@ -137,8 +146,8 @@ bool MSGoogleDrive::onAuthFinished(const QString &html, MSCloudProvider *provide req->setRequestUrl(QStringLiteral("https://www.googleapis.com/oauth2/v4/token")); req->setMethod(QStringLiteral("post")); - req->addQueryItem(QStringLiteral("client_id"), QStringLiteral("834415955748-oq0p2m5dro2bvh3bu0o5bp19ok3qrs3f.apps.googleusercontent.com")); - req->addQueryItem(QStringLiteral("client_secret"), QStringLiteral("YMBWydU58CvF3UP9CSna-BwS")); + req->addQueryItem(QStringLiteral("client_id"), QStringLiteral("251547413210-t1iem90k7hobv18fl2qtfbckic22lml3.apps.googleusercontent.com")); + req->addQueryItem(QStringLiteral("client_secret"), QStringLiteral("k_SO_6HgLC02gZfy3mMy4P46")); req->addQueryItem(QStringLiteral("code"), html.trimmed()); req->addQueryItem(QStringLiteral("grant_type"), QStringLiteral("authorization_code")); req->addQueryItem(QStringLiteral("redirect_uri"), QStringLiteral("http://127.0.0.1:1973")); @@ -290,8 +299,8 @@ bool MSGoogleDrive::refreshToken(){ req->setMethod(QStringLiteral("post")); req->addQueryItem(QStringLiteral("refresh_token"), this->token); - req->addQueryItem(QStringLiteral("client_id"), QStringLiteral("834415955748-oq0p2m5dro2bvh3bu0o5bp19ok3qrs3f.apps.googleusercontent.com")); - req->addQueryItem(QStringLiteral("client_secret"), QStringLiteral("YMBWydU58CvF3UP9CSna-BwS")); + req->addQueryItem(QStringLiteral("client_id"), QStringLiteral("251547413210-t1iem90k7hobv18fl2qtfbckic22lml3.apps.googleusercontent.com")); + req->addQueryItem(QStringLiteral("client_secret"), QStringLiteral("k_SO_6HgLC02gZfy3mMy4P46")); req->addQueryItem(QStringLiteral("grant_type"), QStringLiteral("refresh_token")); req->exec(); @@ -2234,7 +2243,7 @@ bool MSGoogleDrive::remote_file_insert(MSFSObject *object){ } - QString uploadURI = req->getReplyHeader(QByteArray("Location"));// header(QNetworkRequest::LocationHeader).toString(); + QString uploadURI = req->getReplyHeader(QByteArray("location"));// header(QNetworkRequest::LocationHeader).toString(); req->replyText.clear(); @@ -2510,7 +2519,7 @@ bool MSGoogleDrive::remote_file_update(MSFSObject *object){ return false; } - QString uploadURI = req->getReplyHeader(QByteArray("Location"));// header(QNetworkRequest::LocationHeader).toString(); + QString uploadURI = req->getReplyHeader(QByteArray("location"));// header(QNetworkRequest::LocationHeader).toString(); delete(req); diff --git a/ccross-app/src/common/mscloudprovider.cpp b/ccross-app/src/common/mscloudprovider.cpp index 77001c9..0be286e 100644 --- a/ccross-app/src/common/mscloudprovider.cpp +++ b/ccross-app/src/common/mscloudprovider.cpp @@ -501,6 +501,10 @@ QString MSCloudProvider::generateRandom(int count){ void MSCloudProvider::onIncomingConnection(){ + if(this->skipRedirectsCount > 0){ + this->skipRedirectsCount--; + return; + } this->oauthListenerSocket = this->oauthListener->nextPendingConnection(); //QHostAddress pa=this->oauthListenerSocket->co;