Issue
I’m doing an app using flutter that uses AWS Cognito for authentication, but every time the user sign of the app this black screen appears, I’ve searched but could not find out what is wrong, can anyone help me?
Here is my authentication code:
signIn(username, password, context) async {
try {
SignInResult res =
await Amplify.Auth.signIn(username: username, password: password);
if (res.isSignedIn) {
Navigator.of(context)
.push(MaterialPageRoute(builder: (context) => HomePage()));
}
print(username);
} on AuthException catch (e) {
print(e.message);
}
}
signOut() async {
try {
await Amplify.Auth.signOut();
} on AuthException catch (e) {
print(e.message);
}
}
And this is how I’m calling the function:
leading: IconButton(
onPressed: () {
AuthService().signOut();
Navigator.of(context).pushReplacementNamed('/');
},
icon: Icon(Icons.arrow_back)),
Solution
When logging out your user with Cognito, you need to pass a redirect URI in your request, so Cognito knows what to do after the sign out has happened. This URI also has to be registered as a possible URL in your app client configuration, in order to determine whether or not this is intended or malicious behaviour.
As you’ve stated in the comments on your question, you have not configured any sign out URI. So Cognito redirects to a blank page since it has no information on how to proceed otherwise.
Answered By – stijndepestel
Answer Checked By – Marilyn (FlutterFixes Volunteer)