Google oAuth invalid QOAuthHttpServerReplyHandler
-
Hello.
google = new QOAuth2AuthorizationCodeFlow; google->setScope("profile email"); QObject::connect(google, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, &QDesktopServices::openUrl); google->setClientIdentifier("topSecretUser" "apps.googleusercontent.com"); google->setClientIdentifierSharedKey("TopSecretPassword"); google->setAuthorizationUrl( QUrl("https://accounts.google.com/o/oauth2/auth")); google->setAccessTokenUrl(QUrl("https://oauth2.googleapis.com/token")); replyHandler = new QOAuthHttpServerReplyHandler(); google->setReplyHandler(replyHandler); google->grant(); QObject::connect(google, &QOAuth2AuthorizationCodeFlow::granted, [this] { qDebug() << "grabreg" << google->token(); });
If i selected my personal e-mail then i see
qt.networkauth.replyhandler: Error transferring https://oauth2.googleapis.com/token - server replied: Bad Request
If i selected my work e-mail then noraml autorization and i got goole token and can get profile and another user information.
What i doing wrong?
Thanks to everyone. -
Hello.
google = new QOAuth2AuthorizationCodeFlow; google->setScope("profile email"); QObject::connect(google, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, &QDesktopServices::openUrl); google->setClientIdentifier("topSecretUser" "apps.googleusercontent.com"); google->setClientIdentifierSharedKey("TopSecretPassword"); google->setAuthorizationUrl( QUrl("https://accounts.google.com/o/oauth2/auth")); google->setAccessTokenUrl(QUrl("https://oauth2.googleapis.com/token")); replyHandler = new QOAuthHttpServerReplyHandler(); google->setReplyHandler(replyHandler); google->grant(); QObject::connect(google, &QOAuth2AuthorizationCodeFlow::granted, [this] { qDebug() << "grabreg" << google->token(); });
If i selected my personal e-mail then i see
qt.networkauth.replyhandler: Error transferring https://oauth2.googleapis.com/token - server replied: Bad Request
If i selected my work e-mail then noraml autorization and i got goole token and can get profile and another user information.
What i doing wrong?
Thanks to everyone.@Darth_Anmiro said in Google oAuth invalid QOAuthHttpServerReplyHandler:
If i selected my work e-mail then noraml autorization and i got goole token and can get profile and another user information
Should that be a property of the authorization service your accessing? I mean, it works with a work e-mail, it doesn't work with a personal e-mail...
What i doing wrong?
Wouldn't it better asking on Google Auth forum?
-
@Darth_Anmiro said in Google oAuth invalid QOAuthHttpServerReplyHandler:
If i selected my work e-mail then noraml autorization and i got goole token and can get profile and another user information
Should that be a property of the authorization service your accessing? I mean, it works with a work e-mail, it doesn't work with a personal e-mail...
What i doing wrong?
Wouldn't it better asking on Google Auth forum?
@Pablo-J-Rogina
No, google service is configured for external users and created in my personal account. And google credentials selected other.
As I understand it, no one has encountered such a problem?
I would ask, but here QOAuthHttpServerReplyHandler, so I decided to start with the qt forum first -
Problem with code, i would create bug on qt bugs, and i hope they fix it
-
Hello.
google = new QOAuth2AuthorizationCodeFlow; google->setScope("profile email"); QObject::connect(google, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, &QDesktopServices::openUrl); google->setClientIdentifier("topSecretUser" "apps.googleusercontent.com"); google->setClientIdentifierSharedKey("TopSecretPassword"); google->setAuthorizationUrl( QUrl("https://accounts.google.com/o/oauth2/auth")); google->setAccessTokenUrl(QUrl("https://oauth2.googleapis.com/token")); replyHandler = new QOAuthHttpServerReplyHandler(); google->setReplyHandler(replyHandler); google->grant(); QObject::connect(google, &QOAuth2AuthorizationCodeFlow::granted, [this] { qDebug() << "grabreg" << google->token(); });
If i selected my personal e-mail then i see
qt.networkauth.replyhandler: Error transferring https://oauth2.googleapis.com/token - server replied: Bad Request
If i selected my work e-mail then noraml autorization and i got goole token and can get profile and another user information.
What i doing wrong?
Thanks to everyone.had the same problem, trying to solve it in a different way .
if you don't care using the consent screen each time you can try :QOAuth2AuthorizationCodeFlow oauth ;// (not sure about syntax) ... ... .. connect(oauth , &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, [=](QUrl url) { QUrlQuery query(url); query.addQueryItem("prompt", "consent"); // Param required to get data everytime query.addQueryItem("access_type", "offline"); // Needed for Refresh Token (as AccessToken expires shortly) url.setQuery(query); QDesktopServices::openUrl(url); });
found it at stackoverflow cant find the link now.