Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- QJsonDocument document = QJsonDocument::fromJson(fileText);
- auto google = new QOAuth2AuthorizationCodeFlow;
- google->setScope("email");
- connect(google, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser,
- &QDesktopServices::openUrl);
- const auto object = document.object();
- const auto settingsObject = object["web"].toObject();
- const QUrl authUri(settingsObject["auth_uri"].toString());
- const auto clientId = settingsObject["client_id"].toString();
- const QUrl tokenUri(settingsObject["token_uri"].toString());
- const auto clientSecret(settingsObject["client_secret"].toString());
- const auto redirectUris = settingsObject["redirect_uris"].toArray();
- const QUrl redirectUri(redirectUris[0].toString()); // Get the first URI
- const auto port = static_cast<quint16>(redirectUri.port()); // Get the port
- google->setAuthorizationUrl(authUri);
- google->setClientIdentifier(clientId);
- google->setAccessTokenUrl(tokenUri);
- google->setClientIdentifierSharedKey(clientSecret);
- auto replyHandler = new QOAuthHttpServerReplyHandler(port, this);
- google->setReplyHandler(replyHandler);
- google->grant();`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement