简体   繁体   English

清楚的示例/文档说明如何使用Google登录我的网络应用程序

[英]Clear example/documentation of how to use Google login for my web app

I maintain an old web app written in C++ & javascript. 我维护一个用C ++和javascript编写的旧Web应用程序。 I have been asked to add Facebook, Google and Twitter login authentication. 我被要求添加Facebook,Google和Twitter登录身份验证。

The Facebook bit went well. Facebook位进展顺利。 I found some simple javascript code on Facebook's developer site http://developers.facebook.com/docs/reference/javascript/ which I added to my login page. 我在Facebook的开发者网站http://developers.facebook.com/docs/reference/javascript/上找到了一些简单的javascript代码,我将其添加到了我的登录页面。 I then altered the C++ login cgi program to recognise callbacks from Facebook, and to log the user in using their email address (which is already held on file). 然后,我更改了C ++登录cgi程序以识别来自Facebook的回调,并使用他们的电子邮件地址(已经保存在文件中)来记录用户。

I'm stuck with the Google bit. 我坚持使用谷歌。 At first I thrashed around on the Google site, but I couldn't find any simple examples. 起初我在Google网站上徘徊,但我找不到任何简单的例子。 I was directed to the libopkele C++ library, but I can't find any instructions on how to use it (and I suspect it is not what I need). 我被引导到libopkele C ++库,但我找不到任何关于如何使用它的说明(我怀疑它不是我需要的)。 Then I found something called Google Friend Connect http://code.google.com/apis/friendconnect/docs/code.html (which, unfortunately, says it is depreciated). 然后我找到了一个名为Google Friend Connect的网站http://code.google.com/apis/friendconnect/docs/code.html (遗憾的是,它已被折旧)。 That contained a nice javascript example, which I put into my website. 这包含一个很好的javascript示例,我将其放入我的网站。 It provides a button that says "Sign in", and when you click it, it pops up a window asking for your email address. 它提供了一个“登录”按钮,当您单击它时,它会弹出一个窗口,询问您的电子邮件地址。 You fill in the address, it says "Connecting to your IDP", then "Redirecting to your IDP", then my post-login page appears in the pop-up window. 您填写地址,显示“连接到您的IDP”,然后“重定向到您的IDP”,然后我的登录后页面出现在弹出窗口中。

Obviously I don't want that - I want it to appear in the original window where they clicked the "Sign in" button. 显然我不希望这样 - 我希望它出现在他们点击“登录”按钮的原始窗口中。

Here is my javascript from the login page: 这是我登录页面上的javascript:

<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 my userStatusUrl is never called. 我发现我的userStatusUrl永远不会被调用。 The callbackUrl is called, but I am not sure what to return from it. 调用callbackUrl,但我不确定从它返回什么。 It seems whatever I return is merely displayed on the page. 似乎我回来的只是显示在页面上。 I saw a passing reference somewhere to returning a json item containing {"registered" : true}, but that didn't work either (here is the exact text I returned from my cgi script): 我在某个地方看到了一个传递引用来返回一个包含{“registered”:true}的json项,但是这也没有用(这是我从cgi脚本返回的确切文本):

Content-Type: application/json
Content-Length: 20

{"registered" : true}

Any help, or pointers to a nice simple implementation appreciated. 任何帮助,或指向一个很好的简单实现赞赏。 (A PHP script that uses external libraries would not be much help!) (使用外部库的PHP脚本不会有太大帮助!)

Have you looked into Google's OpenID? 你看过谷歌的OpenID吗?

Third-party websites and applications can now let visitors sign in using their Google user accounts. 第三方网站和应用程序现在可以让访问者使用他们的Google用户帐户登录。 Federated Login, based on the OpenID standard, frees users from having to set up separate login accounts for different web sites--and frees web site developers from the task of implementing login authentication measures. 联合登录基于OpenID标准,使用户不必为不同的网站设置单独的登录帐户 - 并使网站开发人员免于执行登录身份验证措施的任务。 OpenID achieves this goal by providing a framework in which users can establish an account with an OpenID provider, such as Google, and use that account to sign into any web site that accepts OpenIDs. OpenID通过提供一个框架来实现这一目标,用户可以在其中与OpenID提供商(如Google)建立帐户,并使用该帐户登录任何接受OpenID的网站。 This page describes how to integrate Google's Federated Login for a web site or application. 本页介绍如何为网站或应用程序集成Google的联合登录。

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

最后,我使用了rpxnow.com ,它使用一个简单,文档齐全的界面,通过一系列提供程序提供易于使用的登录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试在我的 web 应用程序上尝试 google plus 登录时,不断收到“超出未经身份验证使用的每日限制。继续使用需要注册” - Keep getting a "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup" when attempting to google plus login on my web app Cloudinary直接上传文档示例不明确 - Cloudinary direct upload documentation example is not clear 如何在 VueJS 应用程序中使用 Google Web 字体? - How to use Google Web Fonts in VueJS app? 如何在谷歌网站中使用谷歌脚本 web 应用程序和多个页面? - How to use google script web app with multiple pages in google site? Google Cloud Endpoints文档之间的差异以及我的应用程序中的哪些差异 - google cloud endpoints discrepancy between documentation, and what works in my app 寻求有关创建将 Google 帐户与我的应用程序关联的方法的体面文档 - Seeking decent documentation on creating a way to link a Google account with my app 一些用户无法登录我的Google应用 - Some users cannot login to my google app 使用Google API登录我的网站 - Login my website use google api 对如何在我的 web 应用程序中将 Stripe 用作 Firebase 的扩展感到困惑 - Confused about how to use Stripe as an extension with Firebase in my web app 如何在Magento 2中将我的商店用作Progressive Web App? - How to use my store as Progressive Web App in Magento 2?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM