我将我的网站设置为使用google+signin

对于登录,谷歌提供了一个或多或少的翻译好的按钮来登录。

编码

<span id="signinButton">
  <span
    class="g-signin"
    data-callback="signinCallback"
    data-clientid="CLIENT_ID"
    data-cookiepolicy="single_host_origin"
    data-requestvisibleactions="http://schemas.google.com/AddActivity"
    data-scope="https://www.googleapis.com/auth/plus.login">
  </span>
</span>

扩展到:

要遵守Google开发者政策,该应用必须提供一种删除应用与帐户之间的关联的方法。 (来自:google account logout and redirect)

该实现很容易,但是据我了解,Google并未提供(样式/目标)断开连接按钮。还是我想念它?
它看起来应该类似/类似登录按钮。

最佳答案

要遵守这些政策,您必须为用户提供一种撤消应用对他们的信息和帐户的访问权的方法。这与注销不同。

参见how to provide that disconnection and revoking of access

用户断开连接后,您将执行条款要求的清理步骤。

这是使用文档中的jQuery的示例。假设您将访问 token 存储在全局变量access_token中:

<script type="text/javascript">
function disconnectUser(access_token) {
  var revokeUrl = 'https://accounts.google.com/o/oauth2/revoke?token=' +
      access_token;

  // Perform an asynchronous GET request.
  $.ajax({
    type: 'GET',
    url: revokeUrl,
    async: false,
    contentType: "application/json",
    dataType: 'jsonp',
    success: function(nullResponse) {
      // Do something now that user is disconnected

      // Start account clean up
    },
    error: function(e) {
      // Handle the error
      // console.log(e);
      // You could point users to manually disconnect if unsuccessful
      // https://plus.google.com/apps
    }
  });
}
// Could trigger the disconnect on a button click
$('#revokeButton').click(disconnectUser);
</script>
<button id="revokeButton">Disconnect</button>

编辑:

如果您希望资源有助于自定义断开按钮的外观以使其与登录按钮的外观相匹配,则可以使用Google+ Platform branding guidelines页面上提供的资源。在该页面上,您可以下载PhotoShop源文件,这些文件可用于为您的站点创建断开连接按钮。您需要按照该页面上的说明进行操作,以遵守品牌推广指南。

网站如何选择提供断开连接选项取决于设计者。一个站点可能更喜欢断开链接,而另一个站点使用按钮,则设计取决于您。

10-06 06:59
查看更多