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. Fr 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));

Token token = await gitterOAuth.signIn(); String accessToken = token.accessToken;

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 auther, Hadrien Lejard, behind the:

The Gitter-Dart repo, where a lot of this library was influenced from https://github.com/dart-flitter/gitter_dart

and the Flutter Webview plugin which this library uses https://github.com/dart-flitter/flutter_webview_plugin

Libraries

auth_code_information
config
flutter_auth
flutter_oauth
i18n
oauth_token
token

Dart

dart:ui
Built-in types and core primitives for a Flutter application. [...]

Core

dart:async
Support for asynchronous programming, with classes such as Future and Stream. [...]
dart:collection
Classes and utilities that supplement the collection support in dart:core. [...]
dart:convert
Encoders and decoders for converting between different data representations, including JSON and UTF-8. [...]
dart:core
Built-in types, collections, and other core functionality for every Dart program. [...]
dart:developer
Interact with developer tools such as the debugger and inspector. [...]
dart:math
Mathematical constants and functions, plus a random number generator. [...]
dart:typed_data
Lists that efficiently handle fixed sized data (for example, unsigned 8 byte integers) and SIMD numeric types. [...]

VM

dart:io
File, socket, HTTP, and other I/O support for non-web applications. [...]
dart:isolate
Concurrent programming using isolates: independent workers that are similar to threads but don't share memory, communicating only via messages. [...]