Expose the full token response in OAuth2Client and OAuth2Decorator.

Reviewed in https://codereview.appspot.com/7301099/.
diff --git a/tests/test_oauth2client.py b/tests/test_oauth2client.py
index b07ac28..f824f60 100644
--- a/tests/test_oauth2client.py
+++ b/tests/test_oauth2client.py
@@ -142,15 +142,17 @@
 
   def test_token_refresh_success(self):
     for status_code in REFRESH_STATUS_CODES:
+      token_response = {'access_token': '1/3w', 'expires_in': 3600}
       http = HttpMockSequence([
         ({'status': status_code}, ''),
-        ({'status': '200'}, '{"access_token":"1/3w","expires_in":3600}'),
+        ({'status': '200'}, simplejson.dumps(token_response)),
         ({'status': '200'}, 'echo_request_headers'),
         ])
       http = self.credentials.authorize(http)
       resp, content = http.request('http://example.com')
       self.assertEqual('Bearer 1/3w', content['Authorization'])
       self.assertFalse(self.credentials.access_token_expired)
+      self.assertEqual(token_response, self.credentials.token_response)
 
   def test_token_refresh_failure(self):
     for status_code in REFRESH_STATUS_CODES:
@@ -165,6 +167,7 @@
       except AccessTokenRefreshError:
         pass
       self.assertTrue(self.credentials.access_token_expired)
+      self.assertEqual(None, self.credentials.token_response)
 
   def test_token_revoke_success(self):
     _token_revoke_test_helper(
@@ -183,6 +186,7 @@
     http = self.credentials.authorize(http)
     resp, content = http.request('http://example.com')
     self.assertEqual(400, resp.status)
+    self.assertEqual(None, self.credentials.token_response)
 
   def test_to_from_json(self):
     json = self.credentials.to_json()
@@ -221,6 +225,10 @@
     except NonAsciiHeaderError:
       pass
 
+    self.credentials.token_response = 'foobar'
+    instance = OAuth2Credentials.from_json(self.credentials.to_json())
+    self.assertEqual('foobar', instance.token_response)
+
 
 class AccessTokenCredentialsTests(unittest.TestCase):
 
diff --git a/tests/test_oauth2client_appengine.py b/tests/test_oauth2client_appengine.py
index 2d95f08..b8e2588 100644
--- a/tests/test_oauth2client_appengine.py
+++ b/tests/test_oauth2client_appengine.py
@@ -29,7 +29,7 @@
 import os
 import time
 import unittest
-import urlparse
+import urllib
 
 try:
     from urlparse import parse_qs
@@ -121,6 +121,7 @@
       'access_token': 'foo_access_token',
       'refresh_token': 'foo_refresh_token',
       'expires_in': 3600,
+      'extra': 'value',
     }
 
   def request(self, token_uri, method, body, headers, *args, **kwargs):
@@ -499,8 +500,13 @@
         'code': 'foo_access_code',
         'state': 'foo_path:xsrfkey123',
         })
-    self.assertEqual('http://localhost/foo_path', response.headers['Location'])
+    parts = response.headers['Location'].split('?', 1)
+    self.assertEqual('http://localhost/foo_path', parts[0])
     self.assertEqual(None, self.decorator.credentials)
+    if self.decorator._token_response_param:
+        response = parse_qs(parts[1])[self.decorator._token_response_param][0]
+        self.assertEqual(Http2Mock.content,
+                         simplejson.loads(urllib.unquote(response)))
 
     m.UnsetStubs()
     m.VerifyAll()
@@ -629,6 +635,10 @@
     self.assertEqual('dummy_revoke_uri', decorator.flow.revoke_uri)
     self.assertEqual(None, decorator.flow.params.get('user_agent', None))
 
+  def test_token_response_param(self):
+    self.decorator._token_response_param = 'foobar'
+    self.test_required()
+
   def test_decorator_from_client_secrets(self):
     decorator = oauth2decorator_from_clientsecrets(
         datafile('client_secrets.json'),