如何添加电话并通过电话 otp 确认注册,而不是使用电子邮件 otp
我正在尝试使用 Cognito 在我的 Flutter 应用程序中实现身份验证。我正在对现有的 userPool 进行身份验证,去年我在我的 React 应用程序中成功使用了该 userPool。
但是,使用 Flutter 我无法获取用户的会话。我能够成功登录,但无法使用该fetchAuthSession()方法获取任何令牌。知道为什么会发生这种情况吗?这是我的一些工作和非工作代码:
这段代码成功了...
Future _usersEmail() async {
try {
var attributes = (await Amplify.Auth.fetchUserAttributes()).toList();
for (var attribute in attributes) {
if (attribute.userAttributeKey == 'email') {
print("user's email is ${attribute.value}");
return '${attribute.value}';
}
}
return 'no email';
} on AuthException catch (e) {
return '${e.message}';
}
}
Run Code Online (Sandbox Code Playgroud)
这段代码也成功了...
Future<bool> _isSignedIn() async {
final CognitoAuthSession session =
await Amplify.Auth.fetchAuthSession() as CognitoAuthSession;
print('_isSignedIn: ${session.isSignedIn}');
return session.isSignedIn;
}
Run Code Online (Sandbox Code Playgroud)
这段代码返回空...
Future _getIdToken() …Run Code Online (Sandbox Code Playgroud)