auth_header 2.1.2

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

auth_header

Utility library to parse and manipulate HTTP Authorisation header

Usage

A simple usage example:

import 'dart:io';
import 'package:auth_header/auth_header.dart';

main() {
  HttpRequest request;  // TODO get from the real request

  List<String> headers = request.headers[HttpHeaders.AUTHORIZATION];
  if(headers is! List) {
    throw new Exception('No authorization header!');
  }

  String header = headers.first;

  AuthHeaders authHeader = new AuthHeaders.fromHeaderStr(header);
  print(authHeader);

  AuthHeaderItem items = new AuthHeaderItem('some-scheme', 'teja');
  String headerManipulated = AuthHeaders.addItemToHeaderStr(header, items);
  print(headerManipulated);

  headerManipulated = AuthHeaders.removeSchemeFromHeaderStr(header, items.authScheme);
  print(headerManipulated);
}

Changelog

2.1.1

  • Fixed bug in addItemToHeaderStr when header is empty

example/auth_header_example.dart

// Copyright (c) 2016, Ravi Teja Gudapati. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

import 'dart:io';
import 'package:auth_header/auth_header.dart';

main() {
  String header = "Basic something-something";
  AuthHeaders authHeader = AuthHeaders.fromHeaderStr(header);
  print(authHeader);

  AuthHeaderItem items = AuthHeaderItem('some-scheme', 'teja');
  String headerManipulated = AuthHeaders.addItemToHeaderStr(header, items);
  print(headerManipulated);

  headerManipulated = AuthHeaders.removeSchemeFromHeaderStr(header, items.authScheme);
  print(headerManipulated);
}

Use this package as a library

1. Depend on it

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


dependencies:
  auth_header: ^2.1.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or 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:auth_header/auth_header.dart';
  
Version Uploaded Documentation Archive
2.1.2 Aug 14, 2018 Go to the documentation of auth_header 2.1.2 Download auth_header 2.1.2 archive
2.1.1 Aug 7, 2018 Go to the documentation of auth_header 2.1.1 Download auth_header 2.1.1 archive
0.0.3 Jul 16, 2017 Go to the documentation of auth_header 0.0.3 Download auth_header 0.0.3 archive
0.0.2 Dec 4, 2016 Go to the documentation of auth_header 0.0.2 Download auth_header 0.0.2 archive
0.0.1 Dec 4, 2016 Go to the documentation of auth_header 0.0.1 Download auth_header 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
64
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]
82
Learn more about scoring.

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

  • Dart: 2.0.0
  • pana: 0.11.8

Platforms

Detected platforms: Flutter, other

Primary library: package:auth_header/auth_header.dart with components: io.

Issues and suggestions

Fix analysis_options.yaml.

We were unable to parse analysis_options.yaml.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.65 <3.0.0
Dev dependencies
test ^1.3.0