Sample application to showcase how to use Qt C++ to authenticate Google apps. I have referred part of the code from Stackoverflow Question answered by Xplatforms. I will keep the repo updated as Qt and Google introduces more changes.
Feel free to improve the code and post your issues
Remember to add networkauth
in the list of Qt module dependencies
QT += networkauth
Please read the comments in the files. I have tried to explain all the details of the code.
Remember to edit the MY_CLIENT_SECRET
, MY_CLIENT_ID
& port_number
(in my case, it is 5476) in googleauth.cpp
this->google->setClientIdentifier("MY_CLIENT_ID");
this->google->setClientIdentifierSharedKey("MY_SECRET_KEY");
auto replyHandler = new QOAuthHttpServerReplyHandler(5476, this);
Initialized the googleauth object
Contains the button which calls the grant()
method of Qt and prompts Google auth on the browser
-
Google console screenshot: Remember to put http://127.0.0.1:your_port instead of http://localhost:your_port else this will result in
redirect_uri mismatch error