I am currently building a flutter app using AWS Amplify, AWS Cognito, AWS DynamoDB. I have successfully connected amplify and cognito. However, I am currently having this error when trying to add new data to DynamoDB

flutter: Mutation failed: ApiException(message: Failed to retrieve authorization token., recoverySuggestion: , underlyingException: The operation couldn’t be completed. (Amplify.AuthError error 6.))

This is the code that I have implemented.

    try {
      String graphQLDocument =
      '''mutation CreateUser(\$email: String!, \$gender: String!, \$birthdate: String!, 
          \$totalVideoTransform: Int!, \$registeredAt: AWSDateTime!, \$lastLoginAt: AWSDateTime!) {
              createUser(input: {email: \$email, gender: \$gender, birthdate: \$birthdate,
              totalVideoTransform: \$totalVideoTransform, registeredAt: \$registeredAt,
              lastLoginAt: \$lastLoginAt})
                  id
                  email
                  gender
                  birthdate
                  totalVideoTransform
                  registeredAt
                  lastLoginAt
              }
          }''';
      var variables = {
        "email": email,
        "gender": gender,
        "birthdate": birthdate,
        "totalVideoTransform": 0,
        "registeredAt": _current_date.toString().substring(0, 8),
        "lastLoginAt": _current_date.toString().substring(0, 8)
      };
      var request = GraphQLRequest<String>(document: graphQLDocument, variables: variables);

      var operation = Amplify.API.mutate(request: request);
      var response = await operation.response;

      var data = response.data;

      print('Mutation result: ' + data);
    } on ApiException catch (e) {
      print('Mutation failed: $e');
    }

How would I be able to fix this problem?