Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Unified Diff: lib/src/utils.dart

Issue 1320523003: Make a bunch of API changes. (Closed) Base URL: git@github.com:dart-lang/oauth2.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/src/utils.dart
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 734c58e2687d9706ac1181a40199dc7fee2cb433..af19f90567edd4af1ac411c1f1db0825397ed8ca 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -4,11 +4,20 @@
library oauth2.utils;
+import 'dart:convert';
+
+import 'package:crypto/crypto.dart';
+
/// Adds additional query parameters to [url], overwriting the original
/// parameters if a name conflict occurs.
Uri addQueryParameters(Uri url, Map<String, String> parameters) => url.replace(
queryParameters: new Map.from(url.queryParameters)..addAll(parameters));
+String basicAuthHeader(String identifier, String secret) {
+ var userPass = Uri.encodeFull(identifier) + ":" + Uri.encodeFull(secret);
+ return "Basic " + CryptoUtils.bytesToBase64(ASCII.encode(userPass));
+}
+
/// Like [String.split], but only splits on the first occurrence of the pattern.
///
/// This will always return a list of two elements or fewer.

Powered by Google App Engine
This is Rietveld 408576698