Skip to content

Latest commit

 

History

History

flutter

README.md

KRDPASS Flutter Sample App

Reference Flutter app for Sign in with KRDPASS.

Prerequisites

  • Flutter 3.44 or newer
  • KRDPASS app on test device/emulator
  • A publicly reachable HTTPS URL for the callback
  • A running backend that performs PAR + token exchange (see the integration guide linked below)

Step-by-Step Setup

  1. Install dependencies:
flutter pub get

This sample targets Flutter SDK v1.6.0 and Android core 1.6.0, both resolved from the published release.

  1. Create local .env from template (required: pubspec.yaml bundles .env as an asset, so the build fails without it):
cp env.example .env

Edit .env values:

CLIENT_ID=your-client-id
REDIRECT_URI=https://your-backend.example.com/_krdpass/oauth/callback
BACKEND_URL=https://your-backend.example.com
KRD_ENVIRONMENT=development

The app rejects the your-...example.com placeholders at startup, and KRD_ENVIRONMENT must be development or production if set.

  1. For the server-mediated flow, stand up a backend that implements PAR + token exchange (see ../server and the integration guide in Related Docs). Point BACKEND_URL at it.

    Set DEMO_UNAUTHENTICATED_TOKEN_ROUTES=true in the server's .env if you want the Refresh and Revoke buttons and the revoke half of Sign Out to work. Those routes are off by default and return 404, deliberately: they attach the server's CLIENT_SECRET to whatever token a caller posts. See ../server/README.md.

  2. Android signing (required for sign-in to succeed):

cp android/key.properties.example android/key.properties   # then point it at the registered keystore

KRDPASS validates the calling app's signing certificate, so this app must be signed with a keystore whose SHA-256 fingerprint is registered against the client. If android/key.properties is missing the build uses the default debug keystore, which is not registered, so sign-in then fails with invalid_client.

  1. iOS: set the Associated Domains host in ios/Runner/Runner.entitlements (applinks:<your-app-universal-link-host>) to match your REDIRECT_URI host.

  2. Run the Flutter sample:

flutter run

Notes

  • .env is declared as a Flutter asset in pubspec.yaml, which means it is copied verbatim into the APK and the IPA and can be extracted from either. Everything in it is public by construction: a client id, a redirect URI, a backend URL. Nothing that has to stay secret can live there.
  • Use your app's Universal Link host for REDIRECT_URI (iOS Associated Domains).

Related Docs