Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. QJsonDocument document = QJsonDocument::fromJson(fileText);
  2.  
  3. auto google = new QOAuth2AuthorizationCodeFlow;
  4. google->setScope("email");
  5. connect(google, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser,
  6. &QDesktopServices::openUrl);
  7. const auto object = document.object();
  8. const auto settingsObject = object["web"].toObject();
  9. const QUrl authUri(settingsObject["auth_uri"].toString());
  10. const auto clientId = settingsObject["client_id"].toString();
  11. const QUrl tokenUri(settingsObject["token_uri"].toString());
  12. const auto clientSecret(settingsObject["client_secret"].toString());
  13. const auto redirectUris = settingsObject["redirect_uris"].toArray();
  14. const QUrl redirectUri(redirectUris[0].toString()); // Get the first URI
  15. const auto port = static_cast<quint16>(redirectUri.port()); // Get the port
  16.  
  17. google->setAuthorizationUrl(authUri);
  18. google->setClientIdentifier(clientId);
  19. google->setAccessTokenUrl(tokenUri);
  20. google->setClientIdentifierSharedKey(clientSecret);
  21.  
  22.  
  23. auto replyHandler = new QOAuthHttpServerReplyHandler(port, this);
  24. google->setReplyHandler(replyHandler);
  25.  
  26. google->grant();`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement