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 { ...@@ -5,14 +5,15 @@ enum Flavor {
class Config { class Config {
static Flavor appFlavor; static Flavor appFlavor;
} static const DEFAULT_APP_HOST = "https://demo1.vereign.com";
const String APP_HOST = "https://demo1.vereign.com";
/* OAuth */ static Map<String, String> getOAuthParams({host = DEFAULT_APP_HOST}) {
const String CLIENT_ID = "123123"; return {
const String CLIENT_SECRET = "123123"; "clientId": "123123",
"clientSecret": "123123",
const String REDIRECT_URL = "app://com.vereign.app/oauth2"; "redirectUrl": "app://com.vereign.app/oauth2",
const String AUTH_ENDPOINT = "$APP_HOST/api/oauth2/authorize"; "authEndpoint": "$host/api/oauth2/authorize",
const String TOKEN_ENDPOINT = "$APP_HOST/api/oauth2/token"; "tokenEndpoint": "$host/api/oauth2/token",
\ No newline at end of file };
}
}
...@@ -20,7 +20,6 @@ class Home extends StatefulWidget { ...@@ -20,7 +20,6 @@ class Home extends StatefulWidget {
const hosts = [ const hosts = [
'https://rosengeorgiev.dev.vereign.com', 'https://rosengeorgiev.dev.vereign.com',
'https://borisdimitrov.dev.vereign.com', 'https://borisdimitrov.dev.vereign.com',
'https://app.vereign.com',
'https://integration.vereign.com', 'https://integration.vereign.com',
'https://staging.vereign.com', 'https://staging.vereign.com',
'https://demo1.vereign.com', 'https://demo1.vereign.com',
...@@ -39,7 +38,7 @@ const hosts = [ ...@@ -39,7 +38,7 @@ const hosts = [
]; ];
class _HomeState extends State<Home> { 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 @override
initState() { initState() {
...@@ -104,15 +103,17 @@ class _HomeState extends State<Home> { ...@@ -104,15 +103,17 @@ class _HomeState extends State<Home> {
} }
startOAuth() { startOAuth() {
var params = Config.getOAuthParams(host: _host);
FlutterAppAuthWrapper.startAuth( FlutterAppAuthWrapper.startAuth(
AuthConfig( AuthConfig(
clientId: CLIENT_ID, clientId: params["clientId"],
clientSecret: CLIENT_SECRET, clientSecret: params["clientSecret"],
redirectUrl: REDIRECT_URL, redirectUrl: params["redirectUrl"],
state: "login", state: "login",
prompt: "consent", prompt: "consent",
endpoint: AuthEndpoint( endpoint: AuthEndpoint(
auth: AUTH_ENDPOINT, token: TOKEN_ENDPOINT), auth: params["authEndpoint"], token: params["tokenEndpoint"]),
scopes: [ scopes: [
"user_account_status", "user_account_status",
"user_territory", "user_territory",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment