Repository navigation
Description
Bug Description
The iOS app fails with "Found invalid character when decoding base64 string" on the login screen, right after a successful Authentik authorization/token exchange. The error appears before any request reaches the backend's /api/v1/auth/sync endpoint — server-side logs confirm the token exchange itself succeeded (POST /application/o/token/ → 200), but the app never calls /api/v1/auth/sync afterwards. This points to the error happening while the app parses/decodes the id_token (or another JWT segment) it just received, before syncing with the backend.
Steps to Reproduce
- Self-hosted deployment (Docker Compose,
docker-compose.prod.yml), OIDC provider = self-hosted Authentik 2026.8.1. - Web login (NextAuth) works correctly end-to-end with a Confidential OAuth2/OpenID provider in Authentik.
- For the iOS app, created a second, separate Public (PKCE, no secret) OAuth2/OpenID provider in Authentik, per the guidance in [Bug]: Mobile app OIDC Login fails #105 — redirect URI
https://<domain>/api/v1/auth/mobile-callback,OIDC_MOBILE_CLIENT_IDset in.envand correctly picked up (confirmed viaGET /api/v1/auth/configreturning the mobile client_id). - Hit
InvalidIssuerErroron/api/v1/auth/sync(401) — root cause: Authentik scopes the OIDC issuer per Application slug by default, and the mobile provider needed its own Application to pass Authentik's access policy check, giving it a different issuer than the web provider. Fixed by setting Issuer mode → "Same identifier is used for all providers" on both the web and mobile providers, so they share one issuer. - After that fix,
InvalidIssuerErroris gone (confirmed via a temporary backend-side log patch on theexcept jwt.PyJWTErrorhandler inapp/utils/oidc.py) — but the app now shows the base64 decode error instead, immediately after the Authentik authorization redirect completes.
Expected Behavior
App successfully calls POST /api/v1/auth/sync with the id_token and logs the user in, same as the web flow.
Actual Behavior
- Authentik authorize + token exchange both succeed (
nginxaccess log:GET /application/o/authorize/...→302,POST /application/o/token/→200, response body present). - App immediately shows:
Found invalid character when decoding base64 string. - Backend logs show no
POST /api/v1/auth/synccall at all for this attempt (confirmed viadocker compose logs backend --timestampscross-referenced against the exact nginx access log timestamps).
Hypothesis
This looks like the classic base64 vs. base64url pitfall: JWT segments are base64url-encoded (-/_, no padding), not standard base64 (+//, padded). If the app decodes the received id_token's payload (e.g., to read exp/sub before sending it to /api/v1/auth/sync) using a standard base64 decoder instead of a base64url-aware one, it would throw exactly this error whenever the token's payload happens to contain a - or _ — which would explain the intermittent nature of this class of bug (a different user hit a similar-looking "Unexpected character: N" JSON parse error in #89, also right after a token was received).
Deployment Type
Docker Compose
AI Service
Ollama (local) — unrelated to auth, AI_INTERNAL_ENABLED=false at the time of this bug
Additional Context
Wanted to flag before filing: I searched existing issues (base64, base64url, atob, id_token decode, authentik issuer, authentik mobile) and found nothing matching this exact symptom — closest are #101/#115/#43/#90, all different OIDC issues already resolved on my end via the fixes described above.
Happy to provide more logs/detail if useful — I don't have the actual id_token saved (short-lived, wasn't captured), so I can't attach one directly.
Steps to Reproduce
- Deploy Wardrowbe via Docker Compose (docker-compose.prod.yml), self-hosted, with Authentik as the OIDC provider.
- Set up web login with a Confidential OAuth2/OpenID provider in Authentik — works correctly end-to-end.
- For the iOS app, create a second, separate Public (PKCE, no secret) OAuth2/OpenID provider in Authentik, per the guidance in [Bug]: Mobile app OIDC Login fails #105 — redirect URI https:///api/v1/auth/mobile-callback, set OIDC_MOBILE_CLIENT_ID in .env to this provider's client_id (confirmed picked up via GET /api/v1/auth/config).
- Hit InvalidIssuerError (401) on /api/v1/auth/sync — Authentik scopes the OIDC issuer per Application slug by default, and the mobile provider needed its own Application (to pass Authentik's access-policy check), giving it a different issuer than the web provider.
- Fix that by setting Issuer mode -> "Same identifier is used for all providers" on both the web and mobile Authentik providers, so they share one issuer.
- Retry login from the iOS app — Authentik authorize + token exchange both succeed, but the app immediately shows "Found invalid character when decoding base64 string" instead of logging in.
Expected Behavior
App successfully calls POST /api/v1/auth/sync with the id_token and logs the user in, same as the web (NextAuth) flow.
Actual Behavior
- Authentik authorize + token exchange both succeed (nginx access log: GET /application/o/authorize/... -> 302, POST /application/o/token/ -> 200, 3946 bytes response body).
- App immediately shows: "Found invalid character when decoding base64 string".
- Backend logs show no POST /api/v1/auth/sync call at all for this attempt (confirmed via
docker compose logs backend --timestampscross-referenced against the exact nginx access log timestamps) — the app fails before it ever reaches the backend.
Hypothesis: classic base64 vs. base64url pitfall. JWT segments are base64url-encoded (-/_, no padding), not standard base64 (+//, padded). If the app decodes the received id_token's payload client-side (e.g. to read exp/sub before sending it to /api/v1/auth/sync) using a standard base64 decoder instead of a base64url-aware one, it would throw exactly this error whenever the token's payload happens to contain a - or _ — which would explain the intermittent nature of this class of bug (a different user hit a similar "Unexpected character: N" JSON parse error in #89, also right after a token was received).
Deployment Type
Docker Compose
Version
ghcr.io/anyesh/wardrowbe:backend-latest / :frontend-latest, pulled 2026-09-25
AI Service
None
Relevant Logs
nginx (SWAG) access log:
GET /application/o/authorize/?code_challenge=...&code_challenge_method=S256&redirect_uri=https%3A%2F%2F<domain>%2Fapi%2Fv1%2Fauth%2Fmobile-callback&client_id=<mobile_client_id>&response_type=code&state=...&scope=openid+email+profile HTTP/2.0" 302
GET /api/v1/auth/mobile-callback?code=...&state=... HTTP/2.0" 302
POST /application/o/token/ HTTP/2.0" 200 3946
backend logs (docker compose logs backend --timestamps), same timeframe:
INFO: 172.18.0.8:xxxxx - "GET /api/v1/auth/mobile-callback?code=...&state=..." 302 Found
(no further request logged — /api/v1/auth/sync never called)Additional Context
Searched existing issues before filing (base64, base64url, atob, id_token decode, authentik issuer, authentik mobile) — no exact match. Closest are #101, #115, #43, #90, all different OIDC issues already resolved on my end via the fixes described above. Don't have the actual id_token saved (short-lived, wasn't captured) so can't attach one directly.
Checklist
- I have searched existing issues to ensure this is not a duplicate
- I have checked the deployment documentation
Activity
github-actions commentedon Sep 25, 2026
Thanks for opening your first issue in Wardrowbe! Please make sure you've checked the CONTRIBUTING guide and the deployment docs. A maintainer will take a look soon.
Sandbox3453 commentedon Nov 16, 2026
Quick update: this now works on my side. After upgrading the self-hosted server from v1.10.1 to v1.13.0 (backend and frontend images), the iOS app signs in through Authentik (public client with PKCE, shared issuer mode) without the “Found invalid character when decoding base64 string” error. Tested on iPad, iOS app version 1.1.3.
I haven’t pinned down which change fixed it. The sign-in identities rework in 1.13.0 (migration 921b8d3bc2b8, one identity per provider) is the most likely candidate. Unless someone still reproduces it, this issue can probably be closed. Thanks!