blue-hamburger-51631
07/26/2024, 1:17 PMchilly-king-10285
07/26/2024, 1:17 PMchilly-king-10285
07/26/2024, 1:18 PMblue-hamburger-51631
07/26/2024, 1:18 PMblue-hamburger-51631
07/26/2024, 1:19 PMchilly-king-10285
07/26/2024, 1:19 PMchilly-king-10285
07/26/2024, 1:19 PMtypescript import { Configuration, FrontendApi, RegistrationFlow, UiNode, UiNodeInputAttributes, } from "@ory/client" import { filterNodesByGroups, isUiNodeInputAttributes, } from "@ory/integrations/ui" import { useEffect, useState } from "react" import { useSearchParams } from "react-router-dom" const frontend = new FrontendApi( new Configuration({ basePath: "<http://localhost:4000>", // Use your local Ory Tunnel URL baseOptions: { withCredentials: true, // we need to include cookies }, }), ) export const Registration = () => { const [flow, setFlow] = useState<RegistrationFlow>() const [searchParams] = useSearchParams() useEffect(() => { // we can redirect the user back to the page they were on before login const returnTo = searchParams.get("return_to") frontend .createBrowserRegistrationFlow({ returnTo: returnTo || "/", // redirect to the root path after login }) .then(({ data: flow }) => { // set the flow data setFlow(flow) }) .catch((err) => { // Couldn't create login flow // handle the error }) }, []) // ... }
This code creates a new registration flow when the Registration
component is mounted. The createBrowserRegistrationFlow
method is used to create the flow. The returnTo
parameter is used to specify where to redirect the user after they have logged in. If the flow is successfully created, it is stored in the flow
state variable. If there is an error creating the flow, it is handled in the catch
block. Please note that this is a basic example and you might need to adjust it according to your needs. For more detailed information, you can refer to the [Ory documentation](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-basic-integration#create-registration-flow).blue-hamburger-51631
07/26/2024, 1:19 PMchilly-king-10285
07/26/2024, 1:19 PMchilly-king-10285
07/26/2024, 1:20 PMdart import 'package:flutter/material.dart'; import 'package:google_sign_in/google_sign_in.dart'; import 'package:one_of/one_of.dart'; import 'package:ory_client/ory_client.dart'; class SignInWithGoogleButton extends StatelessWidget { final String flowId; final OryClient ory; final GoogleSignIn _googleSignIn = GoogleSignIn( scopes: [ 'email', // Add additional scopes, if you require that data in your Jsonnet mapping ], ); SignInWithGoogleButton({super.key, required this.flowId, required this.ory}); void handleGoogleSignIn(GoogleSignInAccount? value) { value?.authentication.then((value) { var idToken = value.idToken; if (idToken == null) { // If we end up here, but there is no ID token, something went wrong print("No idToken found"); return; } // Create the payload for the updateRegistrationFlow endpoint with the idToken from Google var body = UpdateRegistrationFlowWithOidcMethod( (b) => b ..idToken = idToken ..method = 'oidc' ..provider = 'google', ); // Submit the updateRegistrationFlow endpoint with the payload ory.getFrontendApi().updateRegistrationFlow( flow: flowId, updateRegistrationFlowBody: UpdateRegistrationFlowBody( (b) => b..oneOf = OneOf.fromValue1(value: body)), ); }); } @override Widget build(BuildContext context) { return TextButton( child: const Text("Sign in with Google"), onPressed: () => {_googleSignIn.signIn().then(handleGoogleSignIn)}, ); } }
This code creates a Sign in with Google button and handles the sign-in process. When the button is pressed, the user is prompted to sign in with their Google account. After the user signs in, their ID token is used to update the registration flow. For more detailed information on creating a registration flow in Flutter, you may want to refer to the official Ory documentation or the specific guide for the feature you're interested in. [Source](https://www.ory.sh/docs/kratos/social-signin/google#flutter-code-example)blue-hamburger-51631
07/26/2024, 1:21 PMblue-hamburger-51631
07/26/2024, 1:21 PMchilly-king-10285
07/26/2024, 1:21 PMchilly-king-10285
07/26/2024, 1:21 PMblue-hamburger-51631
07/26/2024, 1:28 PMvar body = UpdateRegistrationFlowWithPasskeyMethodBuilder();
print(body);
final response = await _ory.updateRegistrationFlow(
flow: '',
updateRegistrationFlowBody: UpdateRegistrationFlowBody(
(b) => b..oneOf = OneOf.fromValue1(value: body)),
);
print(response);
chilly-king-10285
07/26/2024, 1:28 PMchilly-king-10285
07/26/2024, 1:28 PMNo serializer for 'UpdateRegistrationFlowWithPasskeyMethodBuilder'
, suggests that the serialization for UpdateRegistrationFlowWithPasskeyMethodBuilder
is not defined or not found. In the provided knowledge sources, there is no specific example of using UpdateRegistrationFlowWithPasskeyMethodBuilder
in Flutter. However, the sources do provide information about the updateRegistrationFlow
method and its parameters. Here's a general example of how you might use it: dart var body = UpdateRegistrationFlowWithPasskeyMethod( (b) => b ..method = 'passkey' ..passkey_register = 'your_passkey_here' ..traits = your_traits_object_here ..transient_payload = your_transient_payload_object_here ); final response = await _ory.updateRegistrationFlow( flow: 'your_flow_id_here', updateRegistrationFlowBody: UpdateRegistrationFlowBody( (b) => b..oneOf = OneOf.fromValue1(value: body) ), ); print(response);
Please replace 'your_passkey_here'
, your_traits_object_here
, your_transient_payload_object_here
, and 'your_flow_id_here'
with your actual values. Please note that this is a basic example and you might need to adjust it according to your needs. For more detailed information, you can refer to the [Ory documentation](https://www.ory.sh/docs/kratos/reference/api#operation/updateRegistrationFlow).blue-hamburger-51631
07/26/2024, 1:32 PMchilly-king-10285
07/26/2024, 1:32 PMchilly-king-10285
07/26/2024, 1:33 PM?flow=
URL query parameter in your application. Here are examples for different types of flows: 1. Login Flow: Send a GET request to the /self-service/login/flows?id=<flow-id>
endpoint. bash curl -X GET \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -c cookies.txt \ "https://$<http://PROJECT_SLUG.projects.oryapis.com/self-service/login/flows?id=<your-flow-id|PROJECT_SLUG.projects.oryapis.com/self-service/login/flows?id=<your-flow-id>>"
[Source](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-basic-integration#get-login-flow) 2. Registration Flow: Send a GET request to the /self-service/registration/flows?id=<flow-id>
endpoint. bash curl -X GET \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -c cookies.txt \ "https://$<http://PROJECT_SLUG.projects.oryapis.com/self-service/registration/flows?id=<your-flow-id|PROJECT_SLUG.projects.oryapis.com/self-service/registration/flows?id=<your-flow-id>>"
[Source](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-basic-integration#get-registration-flow) 3. Recovery Flow: Send a GET request to the /self-service/recovery/flows?id=<flow-id>
endpoint. bash curl -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -c cookies.txt \ -b cookies.txt \ "https://$<http://PROJECT_SLUG.projects.oryapis.com/self-service/recovery/flows?id=<your-flow-id|PROJECT_SLUG.projects.oryapis.com/self-service/recovery/flows?id=<your-flow-id>>"
[Source](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-basic-integration#get-recovery-flow) 4. Verification Flow: Send a GET request to the /self-service/verification/flows?id=<flow-id>
endpoint. bash curl -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -b cookies.txt \ -c cookies.txt \ "https://$<http://PROJECT_SLUG.projects.oryapis.com/self-service/verification/flows?id=<your-flow-id|PROJECT_SLUG.projects.oryapis.com/self-service/verification/flows?id=<your-flow-id>>"
[Source](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-basic-integration#get-verification-flow) Please replace <your-flow-id>
and $PROJECT_SLUG
with your actual values.blue-hamburger-51631
07/26/2024, 1:36 PMblue-hamburger-51631
07/26/2024, 1:36 PMchilly-king-10285
07/26/2024, 1:36 PMblue-hamburger-51631
07/26/2024, 1:36 PMchilly-king-10285
07/26/2024, 1:36 PMchilly-king-10285
07/26/2024, 1:36 PMmethod
field, which is non-nullable, is not being set when you're creating an instance of UpdateRegistrationFlowWithPasskeyMethod
. In the UpdateRegistrationFlowWithPasskeyMethod
constructor, you need to set the method
field to 'passkey'
. Here's how you can do it: dart var body = UpdateRegistrationFlowWithPasskeyMethod( (b) => b ..method = 'passkey' // set other fields as necessary );
Please note that you might need to set other fields as necessary according to your needs. For more detailed information, you can refer to the [Ory documentation](https://www.ory.sh/docs/kratos/reference/api#operation/updateRegistrationFlow).blue-hamburger-51631
07/26/2024, 1:42 PMchilly-king-10285
07/26/2024, 1:42 PMchilly-king-10285
07/26/2024, 1:42 PMid
field of the Identity
object is null when the SuccessfulNativeRegistration
object is being deserialized. This field is non-nullable, so it must have a value. The updateRegistrationFlow
method returns a SuccessfulNativeRegistration
object, which includes an Identity
object. The Identity
object should have an id
field that is automatically set by the Ory server. Here's the general structure of a SuccessfulNativeRegistration
object: dart class SuccessfulNativeRegistration { final Identity identity; final Session session; // other fields... }
And here's the general structure of an Identity
object: dart class Identity { final String id; // other fields... }
If the id
field is null, it might be because the registration flow was not completed successfully, or there was an issue with the Ory server. To troubleshoot this issue, you can: 1. Check the status of the Ory server to make sure it's running correctly. 2. Make sure the registration flow is being completed successfully before you call the updateRegistrationFlow
method. 3. Check the native.data!.id
value to make sure it's not null before you call the updateRegistrationFlow
method. If the issue persists, you may want to refer to the official Ory documentation or seek help from the Ory community. [Source](https://www.ory.sh/docs/kratos/reference/api#operation/updateRegistrationFlow)