<@U04UQ68083H> please generate a simple html page ...
# ory-copilot
f
@chilly-king-10285 please generate a simple html page with embedded javascript that creates a new login flow and immediately submits it to redirect the user to google social sign in
c
A message from kapa.ai
Based on the information provided in the extracts, here is a simple HTML page with embedded JavaScript that creates a new login flow and immediately submits it to redirect the user to Google social sign-in. Please note that this is a simplified example and you may need to adjust it according to your specific needs and environment.
Copy code
html <!DOCTYPE html> <html> <head>     <title>Login with Google</title>     <script src="https://unpkg.com/@ory/client"></script> </head> <body>     <button id="login">Sign in with Google</button>      <script>         const frontend = new FrontendApi(             new Configuration({                 basePath: "<http://localhost:4000>", // Use your local Ory Tunnel URL                 baseOptions: {                     withCredentials: true, // we need to include cookies                 },             })         );          document.getElementById('login').addEventListener('click', function() {             frontend                 .createBrowserLoginFlow({                     returnTo: "/", // redirect to the root path after login                     refresh: true,                 })                 .then(({ data: flow }) => {                     // Redirect to Google sign-in                     window.location.href = flow.action;                 })                 .catch((err) => {                     // Couldn't create login flow                     // handle the error                     console.error(err);                 });         });     </script> </body> </html>
This script uses the Ory SDK (
@ory/client
) to create a login flow when the user clicks the "Sign in with Google" button. After the login flow is created, the user is redirected to the Google sign-in page. Please note that this is a simplified example and does not include error handling or other considerations for a production environment. You may need to adjust the code to fit your specific needs and environment. For more information, you can refer to the [Ory documentation](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-basic-integration).