A Flutter OAuth package for performing user authentication for your apps.

Related tags

Auth FlutterOAuth
Overview

Flutter OAuth

A Flutter OAuth package for performing user authentication for your apps.

I've tested this with a small collection of APIs (Buffer, Strava, Unsplash and GitHub). If there is an issue with an API you are trying to work with, please file an issue :)

Authorizing an application

Performing authorization for an API is straight forward using this library. In most cases you will just be able to use the following approach:

final OAuth flutterOAuth = new FlutterOAuth(new Config(
    "https://unsplash.com/oauth/authorize",
    "https://unsplash.com/oauth/token",
    "YOUR_CLIENT_ID",
    "YOUR_CLIENT_SECRET",
    "http://localhost:8080",
    "code"));

This allows you to pass in an Authorization URL, Token request URL, Client ID, Client Secret, Redirect URL and the response type. This should satisfy most requests, but if not then you can pass in other optional parameters for:

  • contentType - This allows you to change the content type for the request. For example, for Spotify API authorization you need to use "application/x-www-form-urlencoded"
final OAuth flutterOAuth = new FlutterOAuth(new Config(
    ...,
    contentType: "application/x-www-form-urlencoded"));
  • parameters - Add your own parameters that this library may not support out-of-the-box. For example, with the GitHub API you can send a state string and scopes to gain authorization for
Map<String, String> customParameters = {"state": "SOME_RANDOM_SECURE_STRING", "scope": "public_repo"};

final OAuth flutterOAuth = new FlutterOAuth(new Config(
    ...,
    parameters: customParameters));
  • headers - Some APIs require you to send custom headers, such as an Authorization Header. Use this parameter if you require this
Map<String, String> headers = {"Authorization": "Basic SOME_BASE_64_STRING"};

final OAuth flutterOAuth = new FlutterOAuth(new Config(
    ...,
    headers: headers));

Then once you have an OAuth instance, you can simply call the performAuthorization() method like so to retrieve a Token instance:

Token token = await flutterOAuth.performAuthorization();
String accessToken = token.accessToken;

Installing

Add the following you your pubspec.yaml dependancies:

dependencies:
  flutter_oauth: "^0.0.1"

Thanks to

Kevin Seqaud for his awesome blog post on Flutter OAuth https://medium.com/@segaud.kevin/facebook-oauth-login-flow-with-flutter-9adb717c9f2e

The author, Hadrien Lejard, behind the:

The Gitter-Dart repo, where a lot of this library was influenced

and the Flutter Webview plugin, which this library uses

Comments
  • Need to upgrade flutter webview plugin dependency

    Need to upgrade flutter webview plugin dependency

    I'm getting errors related to a return type of Future within the flutter_webview_plugin. I checked that repo and those response types have been changed to a generic Future without the . I think you need to update the dependency number to get the latest flutter_webview_plugin.

    opened by matthew-carroll 6
  • Does not work with current Flutter version (not compatible with Dart2)

    Does not work with current Flutter version (not compatible with Dart2)

    [VERBOSE-2:dart_error.cc(16)] Unhandled exception: type 'Future' is not a subtype of type 'Future' #0 FlutterWebviewPlugin.close (package:flutter_webview_plugin/flutter_webview_plugin.dart:73:36) #1 FlutterOAuth.requestCode (package:flutter_oauth/lib/flutter_auth.dart:26:21) #2 OAuth.performAuthorization (package:flutter_oauth/lib/oauth.dart:49:31)

    opened by fvisticot 3
  • Fixed WebView plugin, updated to newest version

    Fixed WebView plugin, updated to newest version

    Currently, Flutter throws an error about expecting Future, but receiving Future. This fixed the error from occurring, but did not show me the WebView plugin (Which is likely my inexperience with API's)

    opened by tristanwilson111 2
  • get state value

    get state value

    After succussfully get auth code how I can get state value for sending own server.

    var result = await appAuth.authorize( AuthorizationTokenRequest( '$clientId', '$redirectUri', discoveryUrl: finalUrl, serviceConfiguration: AuthorizationServiceConfiguration(finalUrl, ""), scopes: ['profile'], ), );

    opened by abroresonaliev 0
  • Faceit OAuth

    Faceit OAuth

    Hi, I'm trying to use Faceit's OAuth Api with your example app but every time I hit authorize it tries to open this url: http://auth-api.team-platform/v1/oauth/login?client_id=CLIENT_ID&response_type=code&redirect_popup=false

    Faceit's auth url is: http://api.faceit.com/auth/v1/oauth/authenticate and the token url: http://api.faceit.com/auth/v1/oauth/token

    opened by fantasia-y 0
  • Cann't use it on Dart 2.5.0

    Cann't use it on Dart 2.5.0

    Running "flutter pub get" in smart_parking_flutter... The current Dart SDK version is 2.5.0.

    Because smart_parking_flutter depends on flutter_oauth any which requires SDK version >=1.8.0 <2.0.0, version solving failed. pub get failed (1) Process finished with exit code 1

    opened by Wassmd 1
  • Configurable local callback server

    Configurable local callback server

    Hi,

    API providers are sometimes very restrictive about redirect uris. Please provide a way to customize the server parameters so that it can match every callback uri. Especially the port number.

    opened by ludoo0d0a 2
  • Doesnt work with latest flutter

    Doesnt work with latest flutter

    Error message is:

    The current Dart SDK version is 2.1.0-dev.5.0.flutter-a2eb050044.
    
    Because flutter_app_delete depends on flutter_oauth any which requires SDK version >=1.8.0 <2.0.0, version solving failed.
    
    opened by mrgithub 6
  • type 'Future<dynamic>' is not a subtype of type 'Future<Null>'

    type 'Future' is not a subtype of type 'Future'

    I tried to create a very basic example. I just created a method like this and called it: `Future _performOAuthLogin(String client_id, String client_secret) { final OAuth flutterOAuth = new FlutterOAuth(new Config( "https://localhost:8888/oauth/authorize", "https://localhost:8888/oauth/token", client_id, client_secret, "http://localhost:8080", "code"));

    return flutterOAuth.performAuthorization();
    

    }`

    This code snippit leads to the following exception: [VERBOSE-2:dart_error.cc(16)] Unhandled exception: type 'Future<dynamic>' is not a subtype of type 'Future<Null>' #0 FlutterWebviewPlugin.close (package:flutter_webview_plugin/flutter_webview_plugin.dart:73:36) #1 FlutterOAuth.requestCode (package:flutter_oauth/lib/flutter_auth.dart:26:21) <asynchronous suspension> #2 OAuth.performAuthorization (package:flutter_oauth/lib/oauth.dart:49:31) <asynchronous suspension>

    Am i doing something wrong?

    opened by Jannis87 2
Owner
Joe Birch
Senior Android Engineer @bufferapp. Brighton, UK.
Joe Birch
Easy third party authentication (OAuth 2.0) for Flutter apps.

visa This is an OAuth 2.0 package that makes it super easy to add third party authentication to flutter apps. It has support for FB, Google, LinkedIn,

Emmanuel Olaojo 135 Dec 23, 2022
WebView OAuth flows for desktop flutter apps

desktop_webview_auth A new flutter plugin project. Getting Started This project is a starting point for a Flutter plug-in package, a specialized packa

Invertase 22 Dec 17, 2022
Flutter Password Validator package helps you to validate user-entered passwords in your flutter app.

Flutter Password Validator Flutter Password Validator package helps you to validate sign-in user-entered passwords with your rules.

Aref Mozafari 26 Dec 14, 2022
Email and Password Authentication In Flutter & Firebase in Flutter 2.2

email_password_flutter_firebase Email and Password Authentication In Flutter & Firebase in Flutter 2.2 Overview This email and password authentication

null 0 Mar 24, 2022
This project is an example of Firebase authentication in a flutter

This project is an example of Firebase authentication in a flutter. This project shows how to implement a full authentication flow in Flutter, using sign Up with email and password, sign in with email and password, and reset password.

Nittin 4 Mar 11, 2022
Authentication pages I made with Flutter and Firebase

Auth-with-Flutter-and-Firebase Authentication pages I made with Flutter and Firebase Overview This email and password authentication is implemented wi

Said Mirzayev 3 Jul 24, 2022
An example of JWT authentication with flutter.

flutter-jwt-auth-template An example of JWT authentication with flutter. Getting Started Clone this repository, and inside its folder, run: flutter pu

Enzo Di Tizio 23 Jan 4, 2023
Flutter implementation of the Quickstart Supabase User Management app.

Supabase Flutter User Management This repo is a quick sample of how you can get started building apps using Flutter and Supabase. You can find a step

Supabase Community 56 Nov 14, 2022
A Flutter package that implements Google Sign In in pure Dart.

A Flutter package that implements Google Sign In in pure Dart. This package is compatible with google_sign_in plugin and works on all platforms Flutter supports but it's intended to be mainly used on Desktop.

Razvan Lung 10 Oct 26, 2022
By using Flutter Local Auth users can authenticate with Fingerprint & Touch ID in Flutter.

Flutter Tutorial - Fingerprint & Touch ID - Local Auth By using Flutter Local Auth users can authenticate with Fingerprint & Touch ID in Flutter. Soci

Johannes Milke 37 Dec 15, 2022
A Flutter plugin for allowing users to authenticate with native Android & iOS Facebook login SDKs.

flutter_facebook_login A Flutter plugin for using the native Facebook Login SDKs on Android and iOS. AndroidX support if you want to avoid AndroidX, u

Iiro Krankka 404 Nov 26, 2022
Flutter Plugin for Sign In with Apple

Apple Sign In - Flutter Plugin Access Sign In with Apple from Flutter. Platform support This plugin currently only supports iOS. There's a JavaScript

Tom Gilder 156 Dec 28, 2022
The Simplest way to Authenticate in Flutter

Most apps need to make API calls. Every API needs authentication, yet no developer wants to deal with authentication. Simple Auth embeds authenticatio

James Clancey 340 Dec 25, 2022
A Flutter wrapper for AppAuth iOS and Android SDKs

flutter_appauth A Flutter plugin that provides a wrapper for native AppAuth SDKs (https://appauth.io) used authenticating and authorizing users. The r

Michael Bui 230 Dec 21, 2022
In this Application Built Using Flutter🎯 along with FireBase 🔥for Managing the data

In this Application Built Using Flutter?? along with FireBase ??for Managing the data, I have Curated a simple?? Login/Sign Up Space along with Authentication!

Aashvi Kothari 4 Oct 9, 2022
An OAuth authentication system built in Flutter using Google OAuth.

An OAuth authentication system built in Flutter using Google OAuth.

Kaushal 0 Sep 20, 2021
Easy third party authentication (OAuth 2.0) for Flutter apps.

visa This is an OAuth 2.0 package that makes it super easy to add third party authentication to flutter apps. It has support for FB, Google, LinkedIn,

Emmanuel Olaojo 135 Dec 23, 2022
A flutter OAuth package for Slack with Firebase Authentication integration.

flutter_slack_oauth_firebase Extension for our flutter_slack_oauth library which adds support for Firebase Authentication and Cloud Firestore. Usage T

Kunstmaan | Accenture Interactive 11 May 18, 2021
WebView OAuth flows for desktop flutter apps

desktop_webview_auth A new flutter plugin project. Getting Started This project is a starting point for a Flutter plug-in package, a specialized packa

Invertase 22 Dec 17, 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