Polymer Google 登录

2024年8月29日 | 1 分钟阅读

Polymer Google 登录元素用于 Google 身份验证,以便与 Google Drive 和 Google+ API 交互。

注意:在使用 API 之前,您必须在 Google Developers Console 中启用它们。

参数解释

clientId: clientId 可以从 Google Developers Console 获取。https://console.developers.google.com/cloud-resource-manager?previousPage=%2F

scopes: 它用于定义必要的权限范围。

requestVisibleActions: 此属性用于代表用户编写应用活动(https://developers.google.com/+/web/app-activities/)。

offline: 此属性用于为您的服务器获取授权码,以保存离线访问令牌(https://developers.google.com/identity/sign-in/web/server-side-flow)。

您可以使用 height、width 和 theme 等属性来设置按钮的样式,从而遵循 Google+ 登录按钮的品牌指南(https://developers.google.com/+/branding-guidelines)。

Polymer Google 登录事件

google-signin-success: 当用户成功通过身份验证时,将触发 signin-success 事件。您可以使用 isAuthorized 属性来注意用户的身份验证状态。

google-signed-out: 当用户注销时,将触发 signed-out 事件。

google-signout-attempted: 当用户尝试注销时,将触发 signout-attempted 事件。

google-signin-offline-success: 当用户尝试注销时,将触发 signin-offline-success 事件。

google-signin-necessary: 当范围需要通过 google-signin-aware 元素请求的额外用户权限时,将触发 signin-necessary 事件。


下一个主题街景全景