| 1 |
# Browser OAuth2 Login Flow |
| 2 |
|
| 3 |
This documents the browser-based OAuth2 Authorization Code flow used by the Cookidoo web application. This flow replaced the deprecated password grant (`grant_type=password`) used by the mobile API. |
| 4 |
|
| 5 |
The flow was reverse-engineered from a HAR (HTTP Archive) recording of a browser login session against `cookidoo.ch`. |
| 6 |
|
| 7 |
## Overview |
| 8 |
|
| 9 |
The login is a multi-step redirect chain across three domains: |
| 10 |
|
| 11 |
1. **cookidoo.{tld}** — the application domain (e.g. `cookidoo.ch`, `cookidoo.de`) |
| 12 |
2. **ciam.prod.cookidoo.vorwerk-digital.com** — the OAuth2/CIAM authorization server |
| 13 |
3. **eu.login.vorwerk.com** — the login UI (renders the credential form) |
| 14 |
|
| 15 |
After successful authentication, session cookies are set on the `cookidoo.{tld}` domain and all subsequent API calls are authenticated via those cookies. |
| 16 |
|
| 17 |
## Redirect Chain |
| 18 |
|
| 19 |
```http |
| 20 |
GET cookidoo.ch/profile/{lang}/login?redirectAfterLogin=... |
| 21 |
→ 302 → cookidoo.ch/oauth2/start?market={cc}&ui_locales={lang}&rd=... |
| 22 |
→ 302 → ciam.prod.cookidoo.vorwerk-digital.com/authz-srv/authz?client_id=tmde2-live-v1&code_challenge=...&redirect_uri=... |
| 23 |
→ 302 → eu.login.vorwerk.com/ciam/login?requestId={REQUEST_ID}&view_type=login&market={cc}&ui_locales={lang} |
| 24 |
→ 200 (HTML login page with form) |
| 25 |
``` |
| 26 |
|
| 27 |
## Step-by-Step |
| 28 |
|
| 29 |
### Step 1: Initiate Login |
| 30 |
|
| 31 |
```http |
| 32 |
GET https://cookidoo.ch/profile/de-CH/login?redirectAfterLogin=%2Ffoundation%2Fde-CH%2Ffor-you |
| 33 |
``` |
| 34 |
|
| 35 |
The client follows all redirects. The OAuth2 proxy at `cookidoo.ch/oauth2/start` generates a PKCE code challenge and sets a `_oauth2_proxy_csrf` cookie. The CIAM authorization server issues a `requestId` and redirects to the login page. |
| 36 |
|
| 37 |
### Step 2: Extract `requestId` |
| 38 |
|
| 39 |
The final page at `eu.login.vorwerk.com/ciam/login` returns HTML containing a form with a hidden `requestId` field: |
| 40 |
|
| 41 |
```html |
| 42 |
<input type="hidden" name="requestId" value="4814594a-fe30-4c74-aad9-eaf750b3b4a3"> |
| 43 |
``` |
| 44 |
|
| 45 |
This `requestId` is required for the credential POST. |
| 46 |
|
| 47 |
### Step 3: POST Credentials |
| 48 |
|
| 49 |
```http |
| 50 |
POST https://ciam.prod.cookidoo.vorwerk-digital.com/login-srv/login |
| 51 |
Content-Type: application/x-www-form-urlencoded |
| 52 |
|
| 53 |
requestId={REQUEST_ID}&username={EMAIL}&password={PASSWORD} |
| 54 |
``` |
| 55 |
|
| 56 |
On success, the server responds with `302` and sets CIAM session cookies: |
| 57 |
|
| 58 |
| Cookie | Domain | Purpose | |
| 59 |
| -------- | -------- | ------- | |
| 60 |
| `cidaas_sid` | `ciam.prod.cookidoo.vorwerk-digital.com` | CIAM session ID (~1 year) | |
| 61 |
| `cidaas_sso` | `ciam.prod.cookidoo.vorwerk-digital.com` | SSO token (~14 days) | |
| 62 |
| `cidaas_rl` | `ciam.prod.cookidoo.vorwerk-digital.com` | Remember login (~14 days) | |
| 63 |
|
| 64 |
The `Location` header redirects to `cookidoo.ch/oauth2/callback?code={AUTH_CODE}&state=...` |
| 65 |
|
| 66 |
### Step 4: OAuth2 Callback |
| 67 |
|
| 68 |
```http |
| 69 |
GET https://cookidoo.ch/oauth2/callback?code={AUTH_CODE}&state={STATE} |
| 70 |
``` |
| 71 |
|
| 72 |
The OAuth2 proxy exchanges the authorization code for tokens and sets the application session cookies: |
| 73 |
|
| 74 |
| Cookie | Domain | Max-Age | Purpose | |
| 75 |
| -------- | -------- | ------- | ------- | |
| 76 |
| `_oauth2_proxy` | `cookidoo.ch` | session | Encrypted session containing access/refresh tokens | |
| 77 |
| `v-authenticated` | `cookidoo.ch` | ~30 days | Authentication signature | |
| 78 |
| `v-is-authenticated` | `cookidoo.ch` | ~30 days | Boolean flag (`true`) | |
| 79 |
|
| 80 |
The `_oauth2_proxy_csrf` cookie is cleared (set to empty, `max-age=0`). |
| 81 |
|
| 82 |
### Step 5: Final Redirect |
| 83 |
|
| 84 |
```http |
| 85 |
GET https://cookidoo.ch/profile/de-CH/login?redirectAfterLogin=... |
| 86 |
→ 307 → /foundation/de-CH/for-you |
| 87 |
``` |
| 88 |
|
| 89 |
The user is now authenticated and redirected to the app. |
| 90 |
|
| 91 |
## Authenticated API Calls |
| 92 |
|
| 93 |
After login, all API calls use cookies automatically: |
| 94 |
|
| 95 |
```http |
| 96 |
GET https://cookidoo.ch/ownership/subscriptions |
| 97 |
Cookie: _oauth2_proxy=...; v-authenticated=...; v-is-authenticated=true |
| 98 |
``` |
| 99 |
|
| 100 |
The OAuth2 proxy translates the session cookies into a Bearer token internally before forwarding to the backend API. |
| 101 |
|
| 102 |
## Token Refresh |
| 103 |
|
| 104 |
Token refresh is handled **transparently** by the OAuth2 proxy. The client does not need to explicitly refresh tokens. The proxy intercepts requests, checks if the access token is still valid, and refreshes it using the stored refresh token if needed. |
| 105 |
|
| 106 |
There are three expiry tiers: |
| 107 |
|
| 108 |
- **Access token**: ~10 minutes (auto-refreshed by proxy) |
| 109 |
- **SSO / remember-login cookies**: ~14 days |
| 110 |
- **Session cookies** (`v-authenticated`): ~30 days |
| 111 |
|
| 112 |
## Cross-Domain Cookies |
| 113 |
|
| 114 |
The login flow crosses multiple domains. When using `aiohttp`, a `CookieJar(unsafe=True)` is required to allow cookies to be sent across domains during the redirect chain. |
| 115 |
|
| 116 |
## Multi-Tenant Support |
| 117 |
|
| 118 |
The login flow is identical across all tenants. Only the domain and language change: |
| 119 |
|
| 120 |
| Tenant | Domain | Example Language | |
| 121 |
| -------- | -------- | ----------------- | |
| 122 |
| CH | `cookidoo.ch` | `de-CH` | |
| 123 |
| DE | `cookidoo.de` | `de-DE` | |
| 124 |
| IT | `cookidoo.it` | `it-IT` | |
| 125 |
| IE | `cookidoo.co.uk` | `en-GB` | |
| 126 |
| PL | `cookidoo.pl` | `pl-PL` | |
| 127 |
|
| 128 |
The CIAM login server (`eu.login.vorwerk.com`) and login-srv (`ciam.prod.cookidoo.vorwerk-digital.com`) are universal across all tenants. |