Skip to content
Snippets Groups Projects
Commit 4882815c authored by Markin Igor's avatar Markin Igor
Browse files

Rework serving OAuth params.

parent f844037c
No related branches found
No related tags found
1 merge request!1Mobile app initial implementation.
......@@ -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",
};
}
}
......@@ -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",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment