flutter_slack_oauth 0.2.0

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

pub package

flutter_slack_oauth

A flutter OAuth package for Slack with a beautiful "Sign in with Slack" button.

Extensions:

Usage

To use this plugin, add flutter_slack_oauth as a dependency in your pubspec.yaml file.

Example

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

void main() {
  runApp(new MaterialApp(
    home: new Scaffold(
      body: new Builder(
        builder: (BuildContext context) {
          return new Center(
            child: new SlackButton(
              clientId: "XXX_CLIENT_ID_XXX",
              clientSecret: "XXX_CLIENT_SECRET_XXX",
              redirectUrl: "https://kunstmaan.github.io/flutter_slack_oauth/success.html",
              onSuccess: () async {
                String accessToken = await Token.getLocalAccessToken();
                UserList users = await slack.getUsers(accessToken);
                
                Scaffold.of(context).showSnackBar(new SnackBar(
                  content: new Text('We found ' + users.users.length.toString() + " users"),
                ));
              },
              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'),
                ));
              },
            ),
          );
        },
      ),
    ),
  ));
}

Don't want to use the bundled OAuth flow?

  • You can also provide your own custom onTap behaviour by manually importing package:flutter_slack_oauth/oauth/generic_slack_button.dart.
  • Or check out flutter_slack_oauth_firebase, where we use the generic_slack_button to integrate with Firebase Auth and Cloud Firestore.

[0.2.0] - 28 September 2018

  • BREAKING - Required for Flutter Release Preview 2
  • Updated deprecated dependencies and Dart 2 issues.

[0.1.1] - 10 April 2018

  • BREAKING - Required for Flutter Beta 2
  • Required changes to support Dart 2 (and Flutter Beta 2).

[0.1.0] - 30 March 2018

  • SlackButton now uses a GenericSlackButton which is not exposed by default.
  • GenericSlackButton can have a custom onTap callback so you can hook up your custom logic, such as binding Firebase Auth.
  • To use GenericSlackButton, you need to manually import package:flutter_slack_oauth/oauth/generic_slack_button.dart, it is not exposed by default.

[0.0.5] - 29 March 2018

  • Formatted with dartfmt

[0.0.4] - 19 March 2018

  • Slack WebView now has action bar so back behaviour is possible on iOS

[0.0.2] - 19 March 2018

  • Initial release
  • Provides a SlackButton widget which is styled like an official "Sign in with Slack" button.
  • Clicking a SlackButton starts a WebView, allowing the user to log in with Slack.
  • SlackButton requires a client id, client secret, and 3 callbacks: onSuccess, onFailure, and onCancelledByUser.
  • The resulting access token is stored in shared preferences (Android) and NSUserDefaults (iOS) (thanks https://github.com/flutter/plugins/tree/master/packages/shared_preferences)
  • Basic /api/users.identity call as PoC.
  • Basic /api/users.list call as PoC.

example/lib/main.dart

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

import 'package:flutter_slack_oauth/oauth/slack.dart' as slack;

void main() {
  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 SlackButton(
              clientId: "XXX_CLIENT_ID_XXX",
              clientSecret: "XXX_CLIENT_SECRET_XXX",
              redirectUrl:
                  "https://kunstmaan.github.io/flutter_slack_oauth/success.html",
              onSuccess: () async {
                String accessToken = await Token.getLocalAccessToken();
                UserList users = await slack.getUsers(accessToken);

                Scaffold.of(context).showSnackBar(new SnackBar(
                      content: new Text('We found ' +
                          users.users.length.toString() +
                          ' users'),
                    ));
              },
              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: ^0.2.0

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/flutter_slack_oauth.dart';
  
Version Uploaded Documentation Archive
0.2.0 Sep 28, 2018 Go to the documentation of flutter_slack_oauth 0.2.0 Download flutter_slack_oauth 0.2.0 archive
0.1.1 Apr 10, 2018 Go to the documentation of flutter_slack_oauth 0.1.1 Download flutter_slack_oauth 0.1.1 archive
0.1.0 Mar 30, 2018 Go to the documentation of flutter_slack_oauth 0.1.0 Download flutter_slack_oauth 0.1.0 archive
0.0.5 Mar 29, 2018 Go to the documentation of flutter_slack_oauth 0.0.5 Download flutter_slack_oauth 0.0.5 archive
0.0.4 Mar 19, 2018 Go to the documentation of flutter_slack_oauth 0.0.4 Download flutter_slack_oauth 0.0.4 archive
0.0.3 Mar 19, 2018 Go to the documentation of flutter_slack_oauth 0.0.3 Download flutter_slack_oauth 0.0.3 archive
0.0.2 Mar 19, 2018 Go to the documentation of flutter_slack_oauth 0.0.2 Download flutter_slack_oauth 0.0.2 archive
0.0.1 Mar 19, 2018 Go to the documentation of flutter_slack_oauth 0.0.1 Download flutter_slack_oauth 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
40
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
66
Learn more about scoring.

We analyzed this package on Oct 10, 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.

Maintenance suggestions

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
flutter_webview_plugin ^0.2.1+2 0.2.1+2
http ^0.11.3+16 0.11.3+17 0.12.0
shared_preferences ^0.4.1 0.4.3
Transitive dependencies
async 2.0.8
charcode 1.1.2
collection 1.14.11
http_parser 3.1.3
meta 1.1.6
path 1.6.2
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
Dev dependencies
test ^0.12.0