Наша старая реализация:
Код: Выделить всё
val task = GoogleSignIn.getSignedInAccountFromIntent(activityResult.data)
val account = try {
task.getResult(ApiException::class.java)
} catch (e: ApiException) {
// Something treatment here
null
}
val serverAuthCode = account?.serverAuthCode
// endpoint call
Код: Выделить всё
val googleIdOption = GetSignInWithGoogleOption.Builder("our serverClientId").build()
val request = GetCredentialRequest.Builder()
.addCredentialOption(googleIdOption)
.build()
val credentialManager = CredentialManager.create(context)
val response = credentialManager.getCredential(context, request)
val credential = response.credential
if (credential is CustomCredential && credential.type == TYPE_GOOGLE_ID_TOKEN_CREDENTIAL) {
try {
val googleIdTokenCredential = GoogleIdTokenCredential.createFrom(credential.data)
// rest of the code and endpoint call
Как нам следует получить serverAuthCode и обеспечить совместимость с нашим сервером?
Подробнее здесь: https://stackoverflow.com/questions/786 ... al-manager
Мобильная версия