Hello everyone, I'm trying to implement ORY auth o...
# general
h
Hello everyone, I'm trying to implement ORY auth on my flutter app. I can't find any documentation to learn how to handle this. Anyone has any idea of how I know how to use the CodeMethod?
Copy code
@override
Future<void> requestOtpCode({required String email}) async {
  try {
    final result = await oryClient.getFrontendApi().createNativeLoginFlow();

    final codeMethod = UpdateLoginFlowWithCodeMethod(
      (b) => b
        ..method = 'code'
        ..identifier = email
        ..csrfToken = '',
    )..toBuilder().build();

    await oryClient.getFrontendApi().updateLoginFlow(
      flow: result.data!.id,
      updateLoginFlowBody: UpdateLoginFlowBody((builder) => builder.oneOf = NO IDEA),
    );
  } catch (e, st) {
    log('$e\n$st', name: 'OryAuthSource.requestOtpCode');
    rethrow;
  }
}
I was able to move on a little to this:
Copy code
@override
Future<void> requestOtpCode({required String email}) async {
  try {
    final result = await oryClient.getFrontendApi().createNativeRegistrationFlow();

    final codeMethod = UpdateLoginFlowWithCodeMethod(
      (b) => b
        ..method = 'code'
        ..identifier = email
        ..csrfToken = '',
    );

    final builder = UpdateRegistrationFlowBodyBuilder()
      ..oneOf = OneOfDynamic(
        typeIndex: 0,
        types: [
          UpdateLoginFlowWithCodeMethod,
        ],
        value: codeMethod,
      );

    await oryClient.getFrontendApi().updateRegistrationFlow(
      flow: result.data!.id,
      updateRegistrationFlowBody: builder.build(),
    );
  } catch (e, st) {
    log('$e\n$st', name: 'OryAuthSource.requestOtpCode');
    rethrow;
  }
}
I installed the OneOf package from pub.dev but know I'm having this exception: [OryAuthSource.requestOtpCode] DioException [bad response]: This exception was thrown because the response has a status code of 400 and RequestOptions.validateStatus was configured to throw for this status code. The status code of 400 has the following meaning: "Client error - the request contains bad syntax or cannot be fulfilled"