Clear example / documentation on how to use Google login for my web application

I support an old web application written in C ++ and javascript. I was asked to add login authentication to Facebook, Google and Twitter.

The Facebook key went well. I found simple javascript code on the developer's website http://developers.facebook.com/docs/reference/javascript/ , which I added to my login page. Then I changed the Cgi program to login to C ++ to recognize Facebook callbacks and to log in to the system using my email address (which is already stored in the file).

I am stuck in google cue ball. At first I pounced on Google, but I did not find simple examples. I was directed to the C ++ libpkele library, but I cannot find any instructions on how to use it (and I suspect that this is not what I need). Then I found something called Google Friend Connect http://code.google.com/apis/friendconnect/docs/code.html (which unfortunately says it is depreciating). This contained a good javascript example that I posted on my website. It provides a button that says โ€œSign in,โ€ and when you click on it, a window appears asking you for an email address. You fill in the address, it says "Connect to your IDP" and then "Redirect to your IDP", then my page appears after a login in a pop-up window.

Obviously, I donโ€™t want this - I want it to appear in the original window, where they clicked the "Login" button.

Here is my javascript from the login page:

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"></script> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/googleapis/0.0.4/googleapis.min.js"></script> <script type="text/javascript" src="//ajax.googleapis.com/jsapi"></script> <script type="text/javascript"> google.load("identitytoolkit", "1", {packages: ["ac"], language:"en"}); </script> <script type="text/javascript"> $(function() { window.google.identitytoolkit.setConfig({ developerKey: "<I put my developer key here>", companyName: "<I put my company name here>", callbackUrl: "http://www.mywebsite.com/cgi-bin/login.cgi", realm: "", userStatusUrl: "http://http://www.mywebsite.com/cgi-bin/loginstatus.cgi", loginUrl: "http://http://www.mywebsite.com/cgi-bin/login.cgi", signupUrl: "http://http://www.mywebsite.com/cgi-bin/login.cgi", homeUrl: "http://www.mywebsite.com", logoutUrl: "http://http://www.mywebsite.com/cgi-bin/logout.cgi", idps: ["Gmail", "GoogleApps", "Yahoo"], tryFederatedFirst: true, useCachedUserStatus: false }); $("#navbar").accountChooser(); }); </script> <div id="navbar"></div> 

I find that my userStatusUrl is never called. CallbackUrl is called, but I'm not sure what to return it. It seems that everything I return is simply displayed on the page. I saw a link passing somewhere to return a json element containing {"registered": true}, but that didn't work either (here is the exact text that I returned from the cgi script):

 Content-Type: application/json Content-Length: 20 {"registered" : true} 

Any help or pointers to a good simple implementation are appreciated. (A PHP script that uses external libraries would not help!)

+4
source share
2 answers

In the end, I used rpxnow.com , which provides easy-to-use login through vendor selection using a single, simple, well-documented interface.

0
source

Have you looked at Google OpenID?

Third-party websites and applications can now allow visitors to log in using their Google user accounts. Federated Login, an OpenID-based standard, frees users from having to set up separate accounts for different websites - and frees website developers from the task of implementing login authentication measures. OpenID achieves this goal by providing a framework in which users can create an account with an OpenID provider such as Google and use this account to sign up to any website that accepts OpenID. This page describes how to integrate Google Federated Login for a website or application.

https://developers.google.com/accounts/docs/OpenID

+1
source

Source: https://habr.com/ru/post/1394406/


All Articles