Я пытаюсь реализовать вход в Google в моем приложении, и все работает нормально, он просит меня выбрать учетную запись при нажатии кнопки входа, но в ответ отправляет мне код 16 «ОТМЕНЕНО» ошибка.
Я установил библиотеку npm. Установим реагирующую-google-sign-in .Тогда я связал это.Я создал новый проект на firebase, скачал оттуда google-services.json и вставил его в android / app.Также сгенерированный релиз SHA1 и добавление в проект Firebase.
componentDidMount() {
GoogleSignin.configure({
//It is mandatory to call this method before attempting to call signIn()
scopes: ['https://www.googleapis.com/auth/drive.readonly'],
// Repleace with your webClientId generated from Firebase console
webClientId:
'my client id',
});
}
Кнопка входа в Google и действие
<TouchableOpacity
onPress={() => _signIn()}
style={{height:50,width:50,borderRadius:50}}
>
<Image
style={{height:50,width:50}}
resizeMode='contain'
source={ImagePath.GOOGLE_ICON}
/>
</TouchableOpacity>
_signIn = async () => {
//Prompts a modal to let the user sign in into your application.
try {
await GoogleSignin.hasPlayServices({
//Check if device has Google Play Services installed.
//Always resolves to true on iOS.
showPlayServicesUpdateDialog: true,
});
const userInfo = await GoogleSignin.signIn();
alert(JSON.stringify(userInfo))
console.log('User Info --> ', userInfo);
this.setState({ userInfo: userInfo });
} catch (error) {
console.log('Message', error.message);
if (error.code === statusCodes.SIGN_IN_CANCELLED) {
console.log('User Cancelled the Login Flow');
} else if (error.code === statusCodes.IN_PROGRESS) {
console.log('Signing In');
} else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
console.log('Play Services Not Available or Outdated');
} else {
alert(JSON.stringify(error))
console.log('Some Other Error Happened',error);
}
}
};
Это моя конфигурация подписи
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
Я ожидаю успешного входа в Google и пользовательских данных в ответ.Будем благодарны за любую помощь. Спасибо