flutter_slack_oauth_firebase 0.2.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 68

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'),
                    ));
              },
            ),
          );
        },
      ),
    ),
  ));
}

[0.2.1] - 18 October 2018

  • BREAKING - Required for Flutter 0.9.4 beta
  • Updated deprecated dependencies.

[0.2.0] - 28 September 2018

  • Updated deprecated dependencies.

[0.0.4] - 28 May 2018

  • Bugfix in tokenReceived function, thanks to js1972 for pointing it out.

[0.0.3] - 18 May 2018

  • Clear the cache and cookies on webview access.

[0.0.2] - 10 April 2018

  • Updated flutter_slack_oauth dependency to support Flutter Beta 2 (and Dart 2).

[0.0.1] - 30 March 2018

  • Initial release
  • The resulting access token is stored in Firebase Firestore in the slackAccessToken collection.
  • User info returned from the Slack login is stored in Firebase Firestore in the users collection.
  • Both collections contain documents with the Slack UID as the document name.

example/lib/main.dart

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'),
                    ));
              },
            ),
          );
        },
      ),
    ),
  ));
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_slack_oauth_firebase: ^0.2.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_slack_oauth_firebase/flutter_slack_oauth_firebase.dart';
  
Version Uploaded Documentation Archive
0.2.1 Oct 18, 2018 Go to the documentation of flutter_slack_oauth_firebase 0.2.1 Download flutter_slack_oauth_firebase 0.2.1 archive
0.2.0 Sep 28, 2018 Go to the documentation of flutter_slack_oauth_firebase 0.2.0 Download flutter_slack_oauth_firebase 0.2.0 archive
0.0.4 May 28, 2018 Go to the documentation of flutter_slack_oauth_firebase 0.0.4 Download flutter_slack_oauth_firebase 0.0.4 archive
0.0.3 May 18, 2018 Go to the documentation of flutter_slack_oauth_firebase 0.0.3 Download flutter_slack_oauth_firebase 0.0.3 archive
0.0.2 Apr 10, 2018 Go to the documentation of flutter_slack_oauth_firebase 0.0.2 Download flutter_slack_oauth_firebase 0.0.2 archive
0.0.1 Mar 30, 2018 Go to the documentation of flutter_slack_oauth_firebase 0.0.1 Download flutter_slack_oauth_firebase 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
36
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
68
Learn more about scoring.

We analyzed this package on Oct 18, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4
  • Flutter: 0.9.5

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/flutter_slack_oauth_firebase.dart.

Run flutter format to format lib/flutter_slack_oauth_firebase.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
firebase_auth ^0.6.2+1 0.6.2+1
flutter 0.0.0
flutter_slack_oauth ^0.2.0 0.2.0
flutter_webview_plugin ^0.2.1+2 0.2.1+2
Transitive dependencies
async 2.0.8
charcode 1.1.2
collection 1.14.11
http 0.11.3+17 0.12.0
http_parser 3.1.3
meta 1.1.6
path 1.6.2
shared_preferences 0.4.3
sky_engine 0.0.99
source_span 1.4.1
string_scanner 1.0.4
typed_data 1.1.6
vector_math 2.0.8