Added text/javascript as a possible content-type response to the _validate method
Some api provider like dropbox core api use text/javascript instead application/json as content-type response
BUG=
R=nweiz@google.com

Review URL: https://codereview.chromium.org//177093006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33001 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/lib/src/handle_access_token_response.dart b/lib/src/handle_access_token_response.dart
index 129f259..11a6fb9 100644
--- a/lib/src/handle_access_token_response.dart
+++ b/lib/src/handle_access_token_response.dart
@@ -34,7 +34,12 @@
   if (contentType != null) {
     contentType = ContentType.parse(contentType);
   }
-  validate(contentType != null && contentType.value == "application/json",
+
+  // The spec requires a content-type of application/json, but some endpoints
+  // (e.g. Dropbox) serve it as text/javascript instead.
+  validate(contentType != null &&
+      (contentType.value == "application/json" ||
+       contentType.value == "text/javascript"),
       'content-type was "$contentType", expected "application/json"');
 
   var parameters;
diff --git a/test/handle_access_token_response_test.dart b/test/handle_access_token_response_test.dart
index a99d8ea..c362868 100644
--- a/test/handle_access_token_response_test.dart
+++ b/test/handle_access_token_response_test.dart
@@ -138,6 +138,11 @@
       expect(credentials.accessToken, equals('access token'));
     });
 
+    test('with a JavScript content-type returns the correct credentials', () {
+      var credentials = handleSuccess(contentType: 'text/javascript');
+      expect(credentials.accessToken, equals('access token'));
+    });
+
     test('with a null access token throws a FormatException', () {
       expect(() => handleSuccess(accessToken: null), throwsFormatException);
     });