A flutter OAuth package for Slack with Firebase Authentication integration.

Overview

pub package

flutter_slack_oauth_firebase

Extension for our flutter_slack_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 Slack is stored in Firebase Firestore in the slackAccessToken collection under a document with the Slack UID as document id.
  • User info returned from the Slack login is stored in Firebase Firestore in the users collection under a document with the Slack UID as document id.
  • You can easily find the Slack 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("Slack OAuth Example"),
      ),
      body: new Builder(
        builder: (BuildContext context) {
          return new Center(
            child: new FirebaseSlackButton(
              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'),
                    ));
              },
            ),
          );
        },
      ),
    ),
  ));
}
You might also like...

Flutter Firebase Authentication

Flutter Firebase Authentication A sample project demonstrating firebase email and password authentication with Flutter. Getting Started You will need

Dec 13, 2021

Learn how to use firebase authentication in flutter

Learn how to use firebase authentication in flutter

Flutter simple firebase authentication with Flutter Bloc Flutter Version: Stable 2.5.1 Login with Google, Facebook, email & anonymously using Firebase

May 4, 2022

Flutter web example with Firebase Authentication, Firestore Collection, BloC Pattern

flutter_auth_web Flutter Firebase auth. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

Feb 26, 2022

Demo Project to show how to use Phone Authentication in Flutter with Firebase backend

Demo Project to show how to use Phone Authentication in Flutter with Firebase backend

Firebase Phone Authentication using Firebase Demo Project to show how to do Phone Authentication in Flutter using Firebase backend. Screenshots At Fir

Sep 27, 2022

Flutter UI with different widgets and firebase authentication email and gmail

Flutter UI with different widgets and firebase authentication email and gmail

flutter_firebase A new Flutter application. Getting Started This project is a starting point for a Flutter application. A few resources to get you sta

Dec 9, 2022

Simple face recognition authentication (Sign up + Sign in) written in Flutter using Tensorflow Lite and Firebase ML vision library.

Simple face recognition authentication (Sign up + Sign in) written in Flutter using Tensorflow Lite and Firebase ML vision library.

FaceNetAuthentication Simple face recognition authentication (Sign up + Sign in) written in Flutter using Tensorflow Lite and Google ML Kit library. S

Jan 9, 2023

This is a sample Flutter Authentication using Firebase

This is a sample Flutter Authentication using Firebase

Flutter is Google's SDK for crafting beautiful, fast user experiences for mobile, web, and desktop from a single codebase. Flutter works with existing

May 11, 2022

flutter ecommerce application with admin side .authentication and storage with the help of firebase

ecommerce A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if thi

Nov 10, 2022

A chat💬 application📱 developed using Flutter and Firebase along with feature of user authentication👩🏼‍💻

Chitty-Chat A chat 💬 application 📱 developed using Flutter and Firebase along with feature of user authentication👩🏼‍💻. Along with it, it has the

Sep 26, 2022
Comments
  • Not signing into Firebase - something wrong with redirectUrl?

    Not signing into Firebase - something wrong with redirectUrl?

    Hi am trying to test out your plugin here and get the example provided to work but can't. The app just hangs on the webview showing the url: "https://kunstmaan.github.io/flutter_slack_oauth/success.html".

    Because the tokenReceived callback (from jsonp in the token function) redirects to the above kuntsmaan.github.io success page; the webview onUrlChanged() handler never finds a path starting with the provided redirectUrl - which in your example code is given as "https://.firebaseapp.com/completed.html".

    If however I change your code such that the tokenReceived function in index.html instead does this:

    window.location.href = "https://<project>.firebaseapp.com/completed.html?customToken=" + data.token;
    

    to match the redirectUrl - then the webviews onUrlChanged handler does match the redirectUrl and the code goes on to call:

    FirebaseUser user =
                  await _auth.signInWithCustomToken(token: customToken);
    

    But this fails with an error stating that its an invalid firebase token...

    Just wondering if this is still working for you. I've been debugging for quite some time but just seem to be struggling and going in circles. ;-)

    ps. All the other parts of the code like the firebase functions seem to be working fine based on their log output and the database is populated with the user data... The token cloud function log states that a firebase token has been successfully created as well...

    opened by js1972 3
Owner
Kunstmaan | Accenture Interactive
Kunstmaan is a Leuven based agency. Since 1998 we have been helping brands make their mark with integrated communication.
Kunstmaan | Accenture Interactive
FLutter Api Integration - Flutter Rest API Integration

Flutter_Rest_Api_integration Flutter_Rest_Api_integration. Preview How To Use To

Rahul Ranjan Singh 0 Feb 17, 2022
Getx and Dio APi-Integration - Flutter RestApi Integration using Dio

Flutter RestApi Integration using Dio. Click this image to find videos==> //Crud

Fsd Ramjan 9 Nov 5, 2022
Integration test - Copy of the official Flutter integration test plugin

integration_test This package enables self-driving testing of Flutter code on de

null 0 Jan 5, 2022
This library provides the optimized and easiest way to authenticate with Mastodon's OAuth 2.0 in your Flutter app 🎯

The Optimized and Easiest Way to Integrate OAuth 2.0 with Mastodon API in Flutter ?? 1. Guide ?? 1.1. Getting Started ⚡ 1.1.1. Install Library 1.1.2.

Mastodon.dart 11 Jul 7, 2023
Flutter firebase auth - Simple implementation of Firebase Authentication using Flutter

FlutterFire Authentication Sample A simple implementation of Firebase Authentica

Souvik Biswas 4 Apr 2, 2022
Connect your flutter app to firebase, use firebase's Authentication. Don't mind my poor UI. 😬

flutter_email_auth A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you start

Syed Muhammad Ahmad 2 May 2, 2022
A Basic Banking Flutter App with the integration of Firebase

Basic Banking Flutter App A Beginner Flutter Project with the integration of Firebase. Report Bug · Install App Table of Contents About The Project Bu

Kishansinh Rathod 11 Oct 24, 2022
Flutter integration for Supabase. This package makes it simple for developers to build secure and scalable products.

supabase_flutter Flutter package for Supabase. What is Supabase Supabase is an open source Firebase alternative. We are a service to: listen to databa

Supabase 251 Jan 7, 2023
Flutter Firebase Complete Authentication with getx

flutfire A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this

AdnanGriezmann 4 Oct 12, 2022
A chat app built on Flutter with firebase authentication and image sharing capability.

Flutter Chat App A one-to-one chat app built on Flutter with firebase authentication and image sharing capability. For help getting started with Flutt

Rohan Taneja 1.1k Dec 27, 2022