bes_auth_flutter 0.0.9 copy "bes_auth_flutter: ^0.0.9" to clipboard
bes_auth_flutter: ^0.0.9 copied to clipboard

Plugin for easy implements "BES" authorization in your app.

example/lib/main.dart

import 'package:bes_auth_flutter/bes_auth_flutter.dart';
import 'package:flutter/material.dart';

// BesAuth besAuth = BesAuth(
//   serviceUrl: "YOURE",
//   redirectPath: "YOURE_REDIRECT_PATH",
//   clientId: "YOURE_CLIENT_ID",
//   clientSecret: "YOURE_CLIENT_SECRET",
// );
final BesAuth besAuth = BesAuth(
  serviceUrl: "bes-dev2.datawiz.io",
  redirectPath: "datawizio.planohero.layout",
  clientId: "z8MitdHazeB4SRnisYSSZZIp3QhCxSNnanksemMJ",
  clientSecret:
      "HZct1BCy5Q7hI95oCQtLyN43naZjloLvdMjfYLGkokKGvdzVYyWIz7NCisdYnbkq1FiDsCQC38ktCqghEqQ5rhf4bIVfZEcTW5xDkHzz4yrFelFwpqbQAXPeRq09wxtJ",
);

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: const LoginPage(),
    );
  }
}

class LoginPage extends StatefulWidget {
  const LoginPage({Key? key}) : super(key: key);

  @override
  _LoginPageState createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  BesSession? _session;

  void _handleAuthificate(BuildContext context) async {
    BesSession? nextSession = await besAuth.authenticate(context);
    setState(() => _session = nextSession);
  }

  void _handleLogout() async {
    if (_session != null) {
      await besAuth.logout(_session!);
    }
    setState(() => _session = null);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('BesAuth example app'),
      ),
      body: Center(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            RaisedButton(
              child: Text("Authificate"),
              onPressed: () => _handleAuthificate(context),
            ),
            const SizedBox(
              width: 50,
            ),
            RaisedButton(
              child: Text("Logout"),
              onPressed: _handleLogout,
            ),
          ],
        ),
      ),
    );
  }
}
2
likes
100
pub points
16%
popularity

Publisher

unverified uploader

Plugin for easy implements "BES" authorization in your app.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, http, webview_flutter

More

Packages that depend on bes_auth_flutter