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. |