Background:
I need to authenticate on my server back-end so I know the client is genuine. In my Android game I connect to Games.API
via GoogleApiClient
.
I only want to have to sign in once, which I want to do via Games.API
, as this gives me many advantages (Google Play Games leaderboards, achievements, etc.)
I have been able to get an authorisation token using GoogleAuthUtil.getToken(...)
which I can do after I sign into Games.API
, which seems to give me a token. Good so far.
But Google says this is not safe and says I should migrate to ID token flow instead. But, as I understand it this approach would require me to use
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
which means instigating an additional sign in to that for Games.API. Furthermore, it is not possible to addApi
both Games.API
and Auth.GOOGLE_SIGN_IN_API
to the same GoogleApiClient
!
Ok, so upgrade to the latest google-play-services (at least r29), using which I can use Games.API
with Games.getGamesServerAuthCode(...)
to obtain an auth token for my server. But this has two problems: (1) it requires Android 6.0 or above which blocks out 80% of the market, and (2) it's deprecated !
Question:
Should I use GoogleAuthUtil.getToken(...)
or not, and if not what are my options given that I only want to sign in using Games.API
?
By sign in I mean present the user with log in visuals. I don't mind signing into something else so long as the user does not have to interact with the sign in...
Note:
I originally asked this question when I first started out. The current question hopefully clarifies the situation.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…