0

I have a game, but I want to backup the user's data without them having to log in as they already sign in to Google Play Games. I use the below code to sign them in:

val signInOption = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
    .requestId()
    .requestEmail()
    .build()
signInClient = GoogleSignIn.getClient(this, signInOption)

if (GoogleSignIn.getLastSignedInAccount(/*context*/ this) != null) {
    showButtons()
} else {
    hideButtons()
}

I know I can get some sort of ID using GoogleSignIn.getLastSignedInAccount(this) but this ID changes, I was using it during testing, but now the app is in production the IDs of all users have changed. My question is, if I use

.requestId()
.requestEmail()

how can I access either the ID or the email to use those to store the user's data? (obviously I'd prefer non-identifiable data like ID)

Lalit Fauzdar
  • 5,953
  • 2
  • 26
  • 50
Maff
  • 441
  • 1
  • 6
  • 27
  • 1
    Look [here](https://stackoverflow.com/a/52272518/8244632) and [here](https://stackoverflow.com/a/54371463/8244632). – Lalit Fauzdar Oct 15 '19 at 15:14
  • Thanks, so do I take it the ID changes as it went from debug to production but it will now stay the same? – Maff Oct 15 '19 at 15:15
  • 1
    As this is mentioned in the official documentation, `You should create two client IDs, one with the release certificate fingerprint and another with the debug certificate fingerprint. Make sure to use the same package name for both. This allows Google Play games services to recognize calls from your linked APKs that are signed with either certificate.`, IDs are expected to differ while in testing and live production. – Lalit Fauzdar Oct 15 '19 at 15:20

0 Answers0