Skip to content
Snippets Groups Projects
Commit 70ea4576 authored by igorwork's avatar igorwork Committed by Markin Igor
Browse files

Integrate OAuth2 lib

parent 33957099
No related branches found
No related tags found
1 merge request!1Mobile app initial implementation.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.vereign.mobile_app">
<uses-permission android:name="android.permission.INTERNET" />
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
......@@ -31,6 +34,7 @@
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
......@@ -38,5 +42,26 @@
android:host="app.vereign.com" />
</intent-filter>
</activity>
<activity
android:name="net.openid.appauth.RedirectUriReceiverActivity"
tools:node="replace">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="app"
android:host="com.vereign.app"
android:path="/oauth2"/>
</intent-filter>
</activity>
<activity
android:name="github.showang.flutterappauthwrapper.OAuthActivity"
android:configChanges="orientation|screenSize"
android:theme="@style/Theme.AppCompat.Translucent" />
</application>
</manifest>
......@@ -5,4 +5,13 @@
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<style name="Theme.AppCompat.Translucent" parent="@style/Theme.AppCompat.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>
org.gradle.jvmargs=-Xmx1536M
android.enableJetifier=true
android.useAndroidX=true
......@@ -17,7 +17,7 @@ class App extends StatefulWidget {
class _AppState extends State<App> {
StreamSubscription _sub;
String _appMode = "oauth";
String _appMode = "app";
@override
initState() {
......@@ -51,7 +51,7 @@ class _AppState extends State<App> {
}
updateAppMode(uri) {
log("Uri ${uri?.toString()}");
if (uri?.path == "/oauth2") {
setState(() {
_appMode = "oauth";
......
import 'package:flutter/material.dart';
import 'package:flutter_web_browser/flutter_web_browser.dart';
import 'package:flutter_app_auth_wrapper/flutter_app_auth_wrapper.dart';
import 'dart:developer';
class Home extends StatefulWidget {
......@@ -10,8 +11,15 @@ class Home extends StatefulWidget {
_HomeState createState() => _HomeState();
}
String clientId = "222222";
String clientSecret = "22222222";
String redirectURL = "app://com.vereign.app/oauth2";
String authEndpoint = "https://gospodinbodurov.dev.vereign.com/api/oauth2/authorize";
String tokenEndpoint = "https://gospodinbodurov.dev.vereign.com/api/oauth2/token";
class _HomeState extends State<Home> {
final _links = ['vereign://app.vereign.com', 'vereign://app.vereign.com/oauth2', 'https://rosengeorgiev.dev.vereign.com', 'https://igormarkin.dev.vereign.com', 'https://gospodinbodurov.dev.vereign.com'];
final _links = ['vereign://app.vereign.com', 'vereign://app.vereign.com/oauth2', 'testredirect://app.vereign.com', 'https://igormarkin.dev.vereign.com', 'https://gospodinbodurov.dev.vereign.com'];
@override
initState() {
......@@ -31,10 +39,26 @@ class _HomeState extends State<Home> {
}
showMode(mode) {
log(mode);
if (mode == "app") {
FlutterWebBrowser.openWebPage(url: 'https://app.vereign.com', androidToolbarColor: Colors.deepPurple);
} else if (mode == "oauth") {
FlutterWebBrowser.openWebPage(url: 'https://app.vereign.com/oauth2', androidToolbarColor: Colors.deepPurple);
FlutterAppAuthWrapper.startAuth(
AuthConfig(
clientId: clientId,
clientSecret: clientSecret,
redirectUrl: redirectURL,
state: "login",
prompt: "consent",
endpoint: AuthEndpoint(
auth: authEndpoint, token: tokenEndpoint),
scopes: [
"user_account_status",
"user_territory",
"user_profile"
],
),
);
}
}
......
......@@ -41,6 +41,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_app_auth_wrapper:
dependency: "direct main"
description:
name: flutter_app_auth_wrapper
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1+3"
flutter_test:
dependency: "direct dev"
description: flutter
......@@ -53,6 +60,20 @@ packages:
relative: true
source: path
version: "0.11.0"
http:
dependency: "direct main"
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.0+2"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.3"
matcher:
dependency: transitive
description:
......
......@@ -26,6 +26,8 @@ dependencies:
# Use
path: ./deps/flutter_web_browser
uni_links: 0.2.0
http: ^0.12.0
flutter_app_auth_wrapper: ^0.1.1+3
dev_dependencies:
flutter_test:
......
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