简体   繁体   English

用户ID在所有OAuth提供程序中是否唯一?

[英]Is user id unique across all OAuth providers?

My website use OAuth to achieve social sign in, we need to create a unique local account for each OAuth users, currently we use String id as an identity of each unique user, but if two users from different OAuth providers with same id there will be collision. 我的网站使用OAuth进行社交登录,我们需要为每个OAuth用户创建一个唯一的本地帐户,当前我们使用String ID作为每个唯一用户的身份,但是如果来自不同OAuth提供商的两个用户使用相同的ID,碰撞。

My questions are: 我的问题是:

  1. Is user id unique across all OAuth providers, such as Facebook, Twitter, Google...? 用户ID在所有OAuth提供程序(例如Facebook,Twitter,Google ...)中是否唯一?
  2. I see some of the providers use String id and some with Long id, is it safe to just convert long id to String and keep unique? 我看到有些提供程序使用String id,有些提供程序使用Long id,将long id转换为String并保持唯一性是否安全?

不可以,用户ID在所有OAuth提供程序中并不是唯一的,但是如果您将其与提供程序ID连接起来,那么它将是唯一的。

Best way to achieve unique is prefix with OAuth provider, 实现唯一性的最佳方法是使用OAuth提供程序作为前缀,

for example if the user Id return by Facebook is xyz12345 then you can use userid as facebook_xyz12345 例如,如果Facebook返回的用户ID为xyz12345,则可以将userid用作facebook_xyz12345

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM