Remove upper case constants (#26)
* Remove usage of upper-case constants.
* update SDK version
* remove stable from Travis config
diff --git a/.travis.yml b/.travis.yml
index 91b73d0..c15fd33 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,8 +2,6 @@
dart:
- dev
-- stable
-
dart_task:
- test: --platform vm,firefox
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4a26b86..ad6d777 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 1.2.1
+
+* Updated SDK version to 2.0.0-dev.17.0
+
# 1.2.0
* Add a `getParameter()` parameter to `new AuthorizationCodeGrant()`, `new
diff --git a/lib/src/credentials.dart b/lib/src/credentials.dart
index 4bd22a1..f40b26d 100644
--- a/lib/src/credentials.dart
+++ b/lib/src/credentials.dart
@@ -119,7 +119,7 @@
var parsed;
try {
- parsed = JSON.decode(json);
+ parsed = jsonDecode(json);
} on FormatException {
validate(false, 'invalid JSON');
}
@@ -164,7 +164,7 @@
///
/// Nothing is guaranteed about the output except that it's valid JSON and
/// compatible with [Credentials.toJson].
- String toJson() => JSON.encode({
+ String toJson() => jsonEncode({
'accessToken': accessToken,
'refreshToken': refreshToken,
'tokenEndpoint':
diff --git a/lib/src/parameters.dart b/lib/src/parameters.dart
index ccbf23e..61a9659 100644
--- a/lib/src/parameters.dart
+++ b/lib/src/parameters.dart
@@ -24,7 +24,7 @@
'Content-Type was "$contentType", expected "application/json"');
}
- var untypedParameters = JSON.decode(body);
+ var untypedParameters = jsonDecode(body);
if (untypedParameters is! Map) {
throw new FormatException(
'Parameters must be a map, was "$untypedParameters"');
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 150fa17..6c3453f 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -11,5 +11,5 @@
String basicAuthHeader(String identifier, String secret) {
var userPass = Uri.encodeFull(identifier) + ":" + Uri.encodeFull(secret);
- return "Basic " + BASE64.encode(ASCII.encode(userPass));
+ return "Basic " + base64Encode(ascii.encode(userPass));
}
diff --git a/pubspec.yaml b/pubspec.yaml
index 8c49603..1b84732 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: oauth2
-version: 1.2.0
+version: 1.2.1
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/oauth2
description: >
@@ -7,7 +7,7 @@
behalf of a user, and making authorized HTTP requests with the user's
OAuth2 credentials.
environment:
- sdk: '>=1.13.0 <2.0.0'
+ sdk: '>=2.0.0-dev.17.0 <2.0.0'
dependencies:
collection: '^1.5.0'
http: '>=0.11.0 <0.12.0'
diff --git a/test/authorization_code_grant_test.dart b/test/authorization_code_grant_test.dart
index 137755c..ec6e71b 100644
--- a/test/authorization_code_grant_test.dart
+++ b/test/authorization_code_grant_test.dart
@@ -157,7 +157,7 @@
containsPair("Authorization", "Basic aWRlbnRpZmllcjpzZWNyZXQ="));
return new Future.value(new http.Response(
- JSON.encode({
+ jsonEncode({
'access_token': 'access token',
'token_type': 'bearer',
}),
@@ -199,7 +199,7 @@
containsPair("Authorization", "Basic aWRlbnRpZmllcjpzZWNyZXQ="));
return new Future.value(new http.Response(
- JSON.encode({
+ jsonEncode({
'access_token': 'access token',
'token_type': 'bearer',
}),
@@ -244,7 +244,7 @@
}));
return new Future.value(new http.Response(
- JSON.encode({
+ jsonEncode({
'access_token': 'access token',
'token_type': 'bearer',
}),
@@ -274,7 +274,7 @@
}));
return new Future.value(new http.Response(
- JSON.encode({
+ jsonEncode({
'access_token': 'access token',
'token_type': 'bearer',
}),
diff --git a/test/client_test.dart b/test/client_test.dart
index 7f59803..c7b4bbe 100644
--- a/test/client_test.dart
+++ b/test/client_test.dart
@@ -46,7 +46,7 @@
expect(request.method, equals('POST'));
expect(request.url.toString(), equals(tokenEndpoint.toString()));
return new Future.value(new http.Response(
- JSON.encode(
+ jsonEncode(
{'access_token': 'new access token', 'token_type': 'bearer'}),
200,
headers: {'content-type': 'application/json'}));
@@ -93,7 +93,7 @@
expect(request.method, equals('POST'));
expect(request.url.toString(), equals(tokenEndpoint.toString()));
return new Future.value(new http.Response(
- JSON.encode(
+ jsonEncode(
{'access_token': 'new access token', 'token_type': 'bearer'}),
200,
headers: {'content-type': 'application/json'}));
diff --git a/test/credentials_test.dart b/test/credentials_test.dart
index fd77efa..039a060 100644
--- a/test/credentials_test.dart
+++ b/test/credentials_test.dart
@@ -81,7 +81,7 @@
"Basic aWQlQzMlQUJudCVDNCVBQmZpZXI6cyVDMyVBQmNyZXQ="));
return new Future.value(new http.Response(
- JSON.encode({
+ jsonEncode({
'access_token': 'new access token',
'token_type': 'bearer',
'refresh_token': 'new refresh token'
@@ -105,7 +105,7 @@
httpClient.expectRequest((http.Request request) {
expect(request.bodyFields['scope'], equals('scope1,scope2'));
return new Future.value(new http.Response(
- JSON.encode({
+ jsonEncode({
'access_token': 'new access token',
'token_type': 'bearer',
'refresh_token': 'new refresh token'
@@ -137,7 +137,7 @@
}));
return new Future.value(new http.Response(
- JSON.encode({
+ jsonEncode({
'access_token': 'new access token',
'token_type': 'bearer',
'refresh_token': 'new refresh token'
@@ -171,7 +171,7 @@
}));
return new Future.value(new http.Response(
- JSON.encode({
+ jsonEncode({
'access_token': 'new access token',
'token_type': 'bearer',
'refresh_token': 'new refresh token'
@@ -205,7 +205,7 @@
"Basic aWQlQzMlQUJudCVDNCVBQmZpZXI6cyVDMyVBQmNyZXQ="));
return new Future.value(new http.Response(
- JSON.encode(
+ jsonEncode(
{'access_token': 'new access token', 'token_type': 'bearer'}),
200,
headers: {'content-type': 'application/json'}));
@@ -238,7 +238,7 @@
}));
return new Future.value(new http.Response(
- JSON.encode({
+ jsonEncode({
'access_token': 'new access token',
'token_type': 'bearer',
'refresh_token': 'new refresh token'
@@ -258,7 +258,7 @@
group("fromJson", () {
oauth2.Credentials fromMap(Map map) =>
- new oauth2.Credentials.fromJson(JSON.encode(map));
+ new oauth2.Credentials.fromJson(jsonEncode(map));
test("should load the same credentials from toJson", () {
// Round the expiration down to milliseconds since epoch, since that's
diff --git a/test/handle_access_token_response_test.dart b/test/handle_access_token_response_test.dart
index e32e13d..c54e54d 100644
--- a/test/handle_access_token_response_test.dart
+++ b/test/handle_access_token_response_test.dart
@@ -81,7 +81,7 @@
test('with a non-string error_description causes a FormatException', () {
expect(
() => handleError(
- body: JSON.encode(
+ body: jsonEncode(
{"error": "invalid_request", "error_description": 12})),
throwsFormatException);
});
@@ -89,14 +89,14 @@
test('with a non-string error_uri causes a FormatException', () {
expect(
() => handleError(
- body: JSON.encode({"error": "invalid_request", "error_uri": 12})),
+ body: jsonEncode({"error": "invalid_request", "error_uri": 12})),
throwsFormatException);
});
test('with a string error_description causes a AuthorizationException', () {
expect(
() => handleError(
- body: JSON.encode({
+ body: jsonEncode({
"error": "invalid_request",
"error_description": "description"
})),
@@ -106,7 +106,7 @@
test('with a string error_uri causes a AuthorizationException', () {
expect(
() => handleError(
- body: JSON.encode({
+ body: jsonEncode({
"error": "invalid_request",
"error_uri": "http://example.com/error"
})),
@@ -123,7 +123,7 @@
refreshToken,
scope}) {
return handle(new http.Response(
- JSON.encode({
+ jsonEncode({
'access_token': accessToken,
'token_type': tokenType,
'expires_in': expiresIn,
@@ -165,10 +165,10 @@
test('with custom getParameters() returns the correct credentials', () {
var body = '_' +
- JSON.encode({'token_type': 'bearer', 'access_token': 'access token'});
+ jsonEncode({'token_type': 'bearer', 'access_token': 'access token'});
var credentials = handle(
new http.Response(body, 200, headers: {'content-type': 'text/plain'}),
- getParameters: (contentType, body) => JSON.decode(body.substring(1)));
+ getParameters: (contentType, body) => jsonDecode(body.substring(1)));
expect(credentials.accessToken, equals('access token'));
expect(credentials.tokenEndpoint.toString(),
equals(tokenEndpoint.toString()));
@@ -177,7 +177,7 @@
test('throws a FormatException if custom getParameters rejects response',
() {
var response = new http.Response(
- JSON.encode({
+ jsonEncode({
'access_token': 'access token',
'token_type': 'bearer',
'expires_in': 24,
@@ -246,7 +246,7 @@
test('with a custom scope delimiter sets the scopes', () {
var response = new http.Response(
- JSON.encode({
+ jsonEncode({
'access_token': 'access token',
'token_type': 'bearer',
'expires_in': null,
diff --git a/test/resource_owner_password_grant_test.dart b/test/resource_owner_password_grant_test.dart
index c8274f0..04d1537 100644
--- a/test/resource_owner_password_grant_test.dart
+++ b/test/resource_owner_password_grant_test.dart
@@ -12,7 +12,7 @@
import 'utils.dart';
-final success = JSON.encode({
+final success = jsonEncode({
"access_token": "2YotnFZFEjr1zCsicMWpAA",
"token_type": "bearer",
"expires_in": 3600,