Expose the full token response in OAuth2Client and OAuth2Decorator.
Reviewed in https://codereview.appspot.com/7301099/.
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'),