diff --git a/lib/config.dart b/lib/config.dart index 1e9fde2835bebdb361c9f780c25bf76f8f031fbe..d6ff251a9859460d82ad7d3718af9277473c6469 100644 --- a/lib/config.dart +++ b/lib/config.dart @@ -5,14 +5,15 @@ enum Flavor { class Config { static Flavor appFlavor; -} - -const String APP_HOST = "https://demo1.vereign.com"; + static const DEFAULT_APP_HOST = "https://demo1.vereign.com"; -/* OAuth */ -const String CLIENT_ID = "123123"; -const String CLIENT_SECRET = "123123"; - -const String REDIRECT_URL = "app://com.vereign.app/oauth2"; -const String AUTH_ENDPOINT = "$APP_HOST/api/oauth2/authorize"; -const String TOKEN_ENDPOINT = "$APP_HOST/api/oauth2/token"; \ No newline at end of file + static Map<String, String> getOAuthParams({host = DEFAULT_APP_HOST}) { + return { + "clientId": "123123", + "clientSecret": "123123", + "redirectUrl": "app://com.vereign.app/oauth2", + "authEndpoint": "$host/api/oauth2/authorize", + "tokenEndpoint": "$host/api/oauth2/token", + }; + } +} diff --git a/lib/src/screens/home.dart b/lib/src/screens/home.dart index 96cf44f48e00fdce80628818d94195e280f6f3b1..48bdfc04cc8bd744db14241835c3d578606e7c55 100644 --- a/lib/src/screens/home.dart +++ b/lib/src/screens/home.dart @@ -20,7 +20,6 @@ class Home extends StatefulWidget { const hosts = [ 'https://rosengeorgiev.dev.vereign.com', 'https://borisdimitrov.dev.vereign.com', - 'https://app.vereign.com', 'https://integration.vereign.com', 'https://staging.vereign.com', 'https://demo1.vereign.com', @@ -39,7 +38,7 @@ const hosts = [ ]; class _HomeState extends State<Home> { - String _host = Config.appFlavor == Flavor.DEVELOPMENT ? hosts[0] : APP_HOST; + String _host = Config.appFlavor == Flavor.DEVELOPMENT ? hosts[0] : Config.DEFAULT_APP_HOST; @override initState() { @@ -104,15 +103,17 @@ class _HomeState extends State<Home> { } startOAuth() { + var params = Config.getOAuthParams(host: _host); + FlutterAppAuthWrapper.startAuth( AuthConfig( - clientId: CLIENT_ID, - clientSecret: CLIENT_SECRET, - redirectUrl: REDIRECT_URL, + clientId: params["clientId"], + clientSecret: params["clientSecret"], + redirectUrl: params["redirectUrl"], state: "login", prompt: "consent", endpoint: AuthEndpoint( - auth: AUTH_ENDPOINT, token: TOKEN_ENDPOINT), + auth: params["authEndpoint"], token: params["tokenEndpoint"]), scopes: [ "user_account_status", "user_territory",