simplici_auth_flutter 1.0.0
simplici_auth_flutter: ^1.0.0 copied to clipboard
A Flutter package for integrating Simplici Auth with Google OAuth in Flutter applications. Provides webview-based authentication with customizable UI and comprehensive OAuth handling.
Simplici Auth Flutter #
A Flutter package for integrating Simplici Auth with Google OAuth in Flutter applications. This package provides webview-based authentication with customizable UI and comprehensive OAuth handling.
Features #
- π Google OAuth Integration: Complete Google OAuth 2.0 flow with authorization code exchange
- π WebView Authentication: Secure webview-based authentication
- π± Cross-Platform: Works on iOS, Android, and Web
- π¨ Customizable UI: Fullscreen webview with custom styling
- π Token Management: Automatic token exchange and refresh handling
- π User Data: Complete user profile information retrieval
- β‘ Hook System: Integration with
window.handleHooks
for custom flows - π‘οΈ Error Handling: Comprehensive error handling and logging
Installation #
Add this to your package's pubspec.yaml
file:
dependencies:
simplici_auth_flutter: ^1.0.0
Then run:
flutter pub get
Usage #
Basic Usage #
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:simplici_auth_flutter/simplici_auth_flutter.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
// Hide system UI for fullscreen experience
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
scaffoldBackgroundColor: Colors.transparent,
),
home: const SimpliciAuthWebView(),
);
}
}
Custom Implementation #
class CustomAuthScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Authentication')),
body: const SimpliciAuthWebView(),
);
}
}
Configuration #
The package automatically handles:
- Google OAuth Configuration: Receives instance details from the webcomponent
- Token Exchange: Exchanges authorization codes for access tokens
- User Information: Retrieves user profile data from Google
- Hook Integration: Calls
window.handleHooks
with authentication data
Data Flow #
- Instance Details: Webcomponent sends Google OAuth configuration
- Authorization: User authenticates via Google OAuth
- Code Exchange: Authorization code is exchanged for access token
- Hook Call:
window.handleHooks
is called with authentication data - User Data: Complete user information is retrieved and set as
sso_user_data
Response Format #
The package sets sso_user_data
with the following structure:
{
"provider": "google",
"access_token": "ya29.a0...",
"code": "4/0AfJohX...",
"redirect_url": "com.googleusercontent.apps...",
"instanceId": "686792efe1934dbaa5b8c988",
"type": "embeded",
"responseType": "json",
"refresh_token": "1//04...",
"expires_in": 3599,
"email": "user@example.com",
"userId": "686d0c009e6a67af37701b79",
"firstName": "John",
"lastName": "Doe",
"hook_result": {
"statusCode": 200,
"message": "ok",
"data": { ... }
}
}
Requirements #
- Flutter SDK:
>=1.17.0
- Dart SDK:
^3.8.1
Dependencies #
webview_flutter: ^4.2.2
flutter_inappwebview: ^6.0.0
http: ^1.1.0
Platform Support #
Platform | Support |
---|---|
Android | β |
iOS | β |
Web | β |
macOS | β |
Linux | β |
Windows | β |
Example #
Check out the example directory for a complete implementation.
Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
License #
This project is licensed under the MIT License - see the LICENSE file for details.
Support #
If you have any questions or need help, please open an issue on GitHub.