<@U04UQ68083H> I know that for mobile apps to logi...
# ory-copilot
m
@chilly-king-10285 I know that for mobile apps to login its expected to use GET self-service/login/api and then POST self-service/login with password, identity and login flow. Can you show me how would be the requests to login through browser?
b
A message from kapa.ai
Certainly! For browser-based applications, the login process is slightly different from mobile apps. Here's how you can perform login requests through a browser: 1. Initialize the login flow: Send a GET request to `/self-service/login/browser`:
Copy code
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/browser|PROJECT_SLUG.projects.oryapis.com/self-service/login/browser>
[Docs > Kratos > Bring-your-own-ui > Integration basics > Login flow](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-basic-integration#login-flow) 2. Submit the login flow: Send a POST request to
/self-service/login
with the flow ID, CSRF token, and login credentials:
Copy code
bash curl -X POST \     -H 'Content-Type: application/json'\     -H 'Accept: application/json' \     -d '{"method":"password","csrf_token":"your-csrf-token","identifier":"<mailto:user@example.com|user@example.com>","password":"verystrongpassword"}' \     -b cookies.txt \     -c cookies.txt \     "https://$<http://PROJECT_SLUG.projects.oryapis.com/self-service/login?flow=<your-flow-id|PROJECT_SLUG.projects.oryapis.com/self-service/login?flow=<your-flow-id>>"
[Docs > Kratos > Bring-your-own-ui > Integration basics > Login flow > Submit login flow](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-basic-integration#submit-login-flow) Key differences for browser-based login: 1. Use
/self-service/login/browser
instead of
/self-service/login/api
to initialize the flow. 2. Include cookies in your requests (
-b cookies.txt -c cookies.txt
). 3. Include the CSRF token in the login submission. 4. The response will set session cookies for authentication instead of returning a session token. Remember to replace
$PROJECT_SLUG
with your actual project slug,
your-csrf-token
with the CSRF token received in the initial response, and
<your-flow-id>
with the flow ID from the initialization response.