Scott Lin
Scott Lin

Reputation: 1562

What is the data type of a Google Account's unique user identifier?

The unique identifier is documented here as being the "sub" field on ID tokens. The "sub" field value is too large to be 64-bit number. Should it just be considered a string then (for the purposes of storing in a database for example)?

In case the linked content ever changes, below are the relevant details.

ID Token Example

{
  "iss":"accounts.google.com",
  "at_hash":"HK6E_P6Dh8Y93mRNtsDB1Q",
  "email_verified":"true",
  "sub":"10769150350006150715113082367",
  "azp":"1234987819200.apps.googleusercontent.com",
  "email":"[email protected]",
  "aud":"1234987819200.apps.googleusercontent.com",
  "iat":1353601026,
  "exp":1353604926
}

sub Description

"An identifier for the user, unique among all Google accounts and never reused. A Google account can have multiple emails at different points in time, but the sub value is never changed. Use sub within your application as the unique-identifier key for the user."

Thanks!

Upvotes: 4

Views: 4003

Answers (2)

Heikki
Heikki

Reputation: 319

From the docs:

An identifier for the user, unique among all Google accounts and never reused. A Google account can have multiple email addresses at different points in time, but the sub value is never changed. Use sub within your application as the unique-identifier key for the user. Maximum length of 255 case-sensitive ASCII characters.

Upvotes: 4

TResponse
TResponse

Reputation: 4125

It is a string you can see that because its in quotes. The numbers as "iat":1353601026 are not in quotes hence being numbers.

Upvotes: 3

Related Questions