社交登录
社交登录(OAuth)是一种开放的认证标准,它允许用户使用另一个网站或应用的账号登录当前的网站或应用。OAuth 让用户在不透露密码的情况下,授予第三方应用访问他们在线账户的权限。OAuth 常用于比如通过第三方应用登录社交媒体账号。这是一种安全又方便的方式,用于验证用户身份并在应用之间共享信息。
🌐 Social Login (OAuth) is an open standard for authentication that allows users to log in to one website or application using their credentials from another website or application. OAuth allows users to grant third-party applications access to their online accounts without sharing their passwords. OAuth is commonly used for things like logging in to a social media account from a third-party app. It is a secure and convenient way to authenticate users and share information between applications.
好处 #
🌐 Benefits
有几个原因说明你可能想在你的应用中添加社交登录:
🌐 There are several reasons why you might want to add social login to your applications:
- 改进的用户体验:用户可以使用现有的社交媒体账号注册和登录你的应用,这比从零创建新账号更快、更方便。这让用户更容易访问你的应用,从而提升他们的整体体验。
- 更好的用户互动:你可以访问关于用户的更多数据和见解,比如他们的兴趣、人口统计信息和社交关系。这可以帮助你更好地定制内容和营销工作,与用户互动得更好,并提供更个性化的体验。
- 增强安全性:社交登录可以通过利用用户登录使用的社交媒体平台的安全措施和认证协议来提高你应用的安全性。这有助于防止未经授权的访问和账号接管。
在 Supabase Auth 中设置社交登录提供商 #
🌐 Set up a social provider with Supabase Auth
Supabase 支持一系列社交提供商。按照这些指南为你的平台配置社交提供商。
🌐 Supabase supports a suite of social providers. Follow these guides to configure a social provider for your platform.
- Apple
- Azure (Microsoft)
- Bitbucket
- Discord
- Figma
- GitHub
- GitLab
- Kakao
- Keycloak
- Notion
- Slack
- Spotify
- Twitch
- WorkOS
- Zoom
需要集成这里没有列出的提供商吗?你可以使用 自定义 OAuth/OIDC 提供商 添加任何兼容 OAuth2 或 OIDC 的提供商。
🌐 Need to integrate with a provider not listed here? You can add any OAuth2 or OIDC-compatible provider using Custom OAuth/OIDC Providers.
提供者令牌 #
🌐 Provider tokens
你可以使用返回的提供者令牌和提供者刷新令牌来向 OAuth 提供者发起 API 调用。例如,你可以使用 Google 提供者令牌代表你的用户访问 Google API。
🌐 You can use the provider token and provider refresh token returned to make API calls to the OAuth provider. For example, you can use the Google provider token to access Google APIs on behalf of your user.
Supabase Auth 不会为用户管理刷新提供者的令牌。你的应用需要使用提供者的刷新令牌来获取新的提供者令牌。如果没有返回提供者的刷新令牌,那可能意味着以下几种情况之一:
🌐 Supabase Auth does not manage refreshing the provider token for the user. Your application will need to use the provider refresh token to obtain a new provider token. If no provider refresh token is returned, then it could mean one of the following:
- OAuth 提供者没有返回刷新令牌
- 需要指定额外的作用域,OAuth 提供者才能返回刷新令牌。
提供者令牌故意不会存储在你项目的数据库中。这是因为提供者令牌可以访问第三方系统中潜在的敏感用户数据。不同的应用需求不同,一个应用的 OAuth 权限可能比另一个宽很多。如果你想在完成 OAuth 流程的浏览器以外使用提供者令牌,建议把它发送到你控制的可信且安全的服务器上。
🌐 Provider tokens are intentionally not stored in your project's database. This is because provider tokens give access to potentially sensitive user data in third-party systems. Different applications have different needs, and one application's OAuth scopes may be significantly more permissive than another. If you want to use the provider token outside of the browser that completed the OAuth flow, it is recommended to send it to a trusted and secure server you control.