auth_header 0.0.3 copy "auth_header: ^0.0.3" to clipboard
auth_header: ^0.0.3 copied to clipboard

outdatedDart 1 only

Utility library to parse and manipulate HTTP Authorisation header

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() {
  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);
}
2
likes
30
pub points
70%
popularity

Publisher

unverified uploader

Utility library to parse and manipulate HTTP Authorisation header

Homepage

Documentation

Documentation

License

BSD-3-Clause (license)

More

Packages that depend on auth_header