Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

flutter slac oauth firebase

extension for our flutter_sl.ack_oauth library which adds support for firebase authentication and cloud firestore.

usage

  • to use this plugin, add flutter_slack_oauth_firebase as a dependency in your pubspec.yaml file.
  • this package depends on firebase auth, so be sure to follow those steps. unlike the documentation for that package, the google sign-in plugin for firebase auth is not required!
  • deploy the firebase functions project in the firebase folder, which is the “backend” logic that will handle the oauth flow. you can follow the steps as specified in the instagram oauth firebase functions sample.

after succesful login

  • the resulting access token for sl.ack is stored in firebase firestore in the sla.ckaccesstoken collection under a document with the sla.ck uid as document id.
  • user info returned from the sla.ck login is stored in firebase firestore in the users collection under a document with the sla.ck uid as document id.
  • you can easily find the sla.ck uid for the current user after login:
firebaseuser user = await _auth.currentuser();
print(user.uid);

full example

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter_slack_oauth_firebase/flutter_slack_oauth_firebase.dart';

void main() {
  final firebaseauth _auth = firebaseauth.instance;

  runapp(new materialapp(
    home: new scaffold(
      appbar: new appbar(
        title: new text("sl.ack oauth example"),
      ),
      body: new builder(
        builder: (buildcontext context) {
          return new center(
            child: new firebasesla.ckbutton(
              clientid: "xxx_client_id_xxx",
              clientsecret: "xxx_client_secret_xxx",
              redirecturl:
              "https://xxx-firebase-project-xxx.firebaseapp.com/completed.html",
              firebaseurl:
              "https://xxx-firebase-project-xxx.firebaseapp.com/index.html",
              onsuccess: () async {
                // get firebase user:
                firebaseuser user = await _auth.currentuser();

                scaffold.of(context).showsnackbar(new snackbar(
                  content: new text('logged in with slack id ' + user.uid),
                ));
              },
              onfailure: () {
                scaffold.of(context).showsnackbar(new snackbar(
                      content: new text('slack login failed'),
                    ));
              },
              oncancelledbyuser: () {
                scaffold.of(context).showsnackbar(new snackbar(
                      content: new text('slack login cancelled by user'),
                    ));
              },
            ),
          );
        },
      ),
    ),
  ));
}


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Top