jaguar_oauth 0.2.0

  • Installing
  • Versions
  • 50


OAuth interceptors for Jaguar.

JaguarOauth2 provides an easy way to initiate an OAuth2 authorization request and handle the authorization response callback.


@Api(path: '/auth')
class AuthRoutes {
  /// Route that initiates the OAuth2 authorization request by redirecting to
  /// authorization endpoint
  @Get(path: '/fb/authreq')
  Response<Uri> fbAuthReq(ctx) => facebook.initiateRequest(ctx);

  /// Route that handles OAuth2 authorization response callback
  @Get(path: '/fb/authorized', mimeType: 'application/json')
  Future<String> fbAuthorized(Context ctx) async {
    // Get the [Client] from authorization response callback
    oauth2.Client client = await facebook.handleResponse(ctx);
    // Use Facebook OAuth2 APIs
    final resp = await client.get('');
    return resp.body;

  /// Facebook OAuth2 configuration
  JaguarOauth2 get facebook => new JaguarOauth2(
      key: fbOauthKey,
      secret: fbOauthSecret,
      authorizationEndpoint: '',
      tokenEndpoint: '',
      callback: baseUrl + '/api/auth/fb/authorized',
      scopes: ['email']);

Example usage outside Jaguar routes

main(List<String> args) async {
  // Create the OAuth2 config
  final config = new JaguarOauth2(
      key: fbOauthKey, // Facebook OAuth key
      secret: fbOauthSecret, // Facebook OAuth secret
      authorizationEndpoint: '',
      tokenEndpoint: '',
      callback: 'http://localhost:5555/api/auth/fb/login/authorized',
      scopes: ['email']);

  // Print the authorization url
  print('Authorization url: ');

  print('Open the authorization URL in the browser.');
  print('Get the response code from Facebook.');

  // Get the response code
  stdout.write('Enter the code: ');
  String code = stdin.readLineSync();

  // Get HTTP [Client] from authorization response
  final Client client = await config.handleResponseWithParam({'code': code});

  // Fetch user profile
  final resp = await client.get('');



  • Moved to Jaguar 0.6.x
  • Helper functions rather than Interceptors

1. Depend on it

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

  jaguar_oauth: "^0.2.0"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:jaguar_oauth/jaguar_oauth.dart';
Version Uploaded Documentation Archive
0.2.0 Nov 7, 2017 Go to the documentation of jaguar_oauth 0.2.0 Download jaguar_oauth 0.2.0 archive
0.1.0 Jun 7, 2017 Go to the documentation of jaguar_oauth 0.1.0 Download jaguar_oauth 0.1.0 archive
0.0.2 Feb 19, 2017 Go to the documentation of jaguar_oauth 0.0.2 Download jaguar_oauth 0.0.2 archive
0.0.1 Feb 8, 2017 Go to the documentation of jaguar_oauth 0.0.1 Download jaguar_oauth 0.0.1 archive


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1


Describes how popular the package is relative to other packages. [more]
0 / 100
Code health derived from static analysis. [more]
100 / 100
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]


Detected platforms: other

Primary library: package:jaguar_oauth/jaguar_oauth.dart with components: io, mirrors.


  • Fix .analysis_options.

    We were unable to parse .analysis_options.

  • The description is too short.

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

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use jaguar_oauth.dart.

  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.

  • Enable strong mode analysis.

    Strong mode helps you to detect bugs and potential issues earlier.Start your analysis_options.yaml file with the following:

      strong-mode: true


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <2.0.0
jaguar ^0.6.19 0.6.29 1.3.4
oauth2 ^1.1.0 1.1.0
Transitive dependencies
args 1.2.0 1.3.0
async 2.0.3
charcode 1.1.1
collection 1.14.5
convert 2.0.1
crypto 2.0.2+1
dice 1.7.0
http 0.11.3+16
http_parser 3.1.1
http_server 0.9.7
intl 0.15.2
logging 0.11.3+1
meta 1.1.2
mime 0.9.6
mustache 0.2.5+1 1.0.0
path 1.5.1
quiver_hashcode 1.0.0
source_span 1.4.0
stack_trace 1.9.1
string_scanner 1.0.2
typed_data 1.1.5
yaml 2.1.13
Dev dependencies
jaguar_facebook_client >=0.0.4 <0.1.0
test >=0.12.0 <0.13.0