Remove user_agent from app engine helpers.
diff --git a/oauth2client/appengine.py b/oauth2client/appengine.py
index a9766c7..439a579 100644
--- a/oauth2client/appengine.py
+++ b/oauth2client/appengine.py
@@ -71,7 +71,7 @@
AssertionFlowCredentials objects may be safely pickled and unpickled.
"""
- def __init__(self, scope, user_agent,
+ def __init__(self, scope,
audience='https://accounts.google.com/o/oauth2/token',
assertion_type='http://oauth.net/grant_type/jwt/1.0/bearer',
token_uri='https://accounts.google.com/o/oauth2/token', **kwargs):
@@ -79,7 +79,6 @@
Args:
scope: string, scope of the credentials being requested.
- user_agent: string, The HTTP User-Agent to provide for this application.
audience: string, The audience, or verifier of the assertion. For
convenience defaults to Google's audience.
assertion_type: string, Type name that will identify the format of the
@@ -94,7 +93,7 @@
super(AppAssertionCredentials, self).__init__(
assertion_type,
- user_agent,
+ None,
token_uri)
def _generate_assertion(self):
@@ -261,8 +260,7 @@
decorator = OAuth2Decorator(
client_id='837...ent.com',
client_secret='Qh...wwI',
- scope='https://www.googleapis.com/auth/buzz',
- user_agent='my-sample-app/1.0')
+ scope='https://www.googleapis.com/auth/buzz')
class MainHandler(webapp.RequestHandler):
@@ -275,7 +273,7 @@
"""
- def __init__(self, client_id, client_secret, scope, user_agent,
+ def __init__(self, client_id, client_secret, scope,
auth_uri='https://accounts.google.com/o/oauth2/auth',
token_uri='https://accounts.google.com/o/oauth2/token'):
@@ -285,14 +283,13 @@
client_id: string, client identifier.
client_secret: string client secret.
scope: string, scope of the credentials being requested.
- user_agent: string, HTTP User-Agent to provide for this application.
auth_uri: string, URI for authorization endpoint. For convenience
defaults to Google's endpoints but any OAuth 2.0 provider can be used.
token_uri: string, URI for token endpoint. For convenience
defaults to Google's endpoints but any OAuth 2.0 provider can be used.
"""
- self.flow = OAuth2WebServerFlow(client_id, client_secret, scope,
- user_agent, auth_uri, token_uri)
+ self.flow = OAuth2WebServerFlow(client_id, client_secret, scope, None,
+ auth_uri, token_uri)
self.credentials = None
self._request_handler = None
diff --git a/oauth2client/client.py b/oauth2client/client.py
index 523a185..f547428 100644
--- a/oauth2client/client.py
+++ b/oauth2client/client.py
@@ -202,9 +202,12 @@
"""Generate the headers that will be used in the refresh request
"""
headers = {
- 'user-agent': self.user_agent,
'content-type': 'application/x-www-form-urlencoded',
}
+
+ if self.user_agent is not None:
+ headers['user-agent'] = self.user_agent
+
return headers
def _refresh(self, http_request):
@@ -289,10 +292,12 @@
if headers == None:
headers = {}
headers['authorization'] = 'OAuth ' + self.access_token
- if 'user-agent' in headers:
- headers['user-agent'] = self.user_agent + ' ' + headers['user-agent']
- else:
- headers['user-agent'] = self.user_agent
+
+ if self.user_agent is not None:
+ if 'user-agent' in headers:
+ headers['user-agent'] = self.user_agent + ' ' + headers['user-agent']
+ else:
+ headers['user-agent'] = self.user_agent
resp, content = request_orig(uri, method, body, headers,
redirections, connection_type)
@@ -494,9 +499,12 @@
'scope': self.scope,
})
headers = {
- 'user-agent': self.user_agent,
'content-type': 'application/x-www-form-urlencoded',
}
+
+ if self.user_agent is not None:
+ headers['user-agent'] = self.user_agent
+
if http is None:
http = httplib2.Http()
resp, content = http.request(self.token_uri, method='POST', body=body,