Question

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.

My questions are:

  1. Is user id unique across all OAuth providers, such as 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?
Was it helpful?

Solution

No, user id is not unique across all OAuth providers, but if you connect it with the provider id then it will be.

OTHER TIPS

Best way to achieve unique is prefix with OAuth provider,

for example if the user Id return by Facebook is xyz12345 then you can use userid as facebook_xyz12345

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top