kulpa / google-api-python-client

Automatically exported from code.google.com/p/google-api-python-client
Other
0 stars 0 forks source link

oauth2client/appengine.py broken with webapp2/python27/wsgi/threadsafe:yes #111

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
application: google.com:proppy-bigquery-ae-logs
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /oauth2callback
  script: oauth2client.appengine.application

What is the expected output? What do you see instead?

header values must be str, got 'unicode'
Traceback (most recent call last):
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.1/webapp2.py", line 1547, in __call__
    return response(environ, start_response)
  File "/base/python27_runtime/python27_lib/versions/third_party/webob-1.1.1/webob/response.py", line 939, in __call__
    start_response(self.status, headerlist)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 147, in _StartResponse
    _GetTypeName(header[1]))
InvalidResponseError: header values must be str, got 'unicode'

Original issue reported on code.google.com by pro...@google.com on 1 Mar 2012 at 3:59

GoogleCodeExporter commented 9 years ago
No error with threadsafe:no/cgi:

application: google.com:proppy-bigquery-ae-logs
version: 1
runtime: python27
api_version: 1
threadsafe: no

handlers:
- url: /oauth2callback
  script: oauth2client/appengine.py

Original comment by pro...@google.com on 1 Mar 2012 at 4:00

GoogleCodeExporter commented 9 years ago
It looks like in some conditions the redirect uri ends up being unicode instead 
of a string.

This should fix it:

   http://codereview.appspot.com/5712052/

Original comment by jcgregorio@google.com on 1 Mar 2012 at 6:17

GoogleCodeExporter commented 9 years ago
This issue was closed by revision bd4160780c28.

Original comment by jcgregorio@google.com on 2 Mar 2012 at 8:36

GoogleCodeExporter commented 9 years ago
Is this fix likely to be in the 1.6.4 release?

Original comment by webmas...@jgrall.com on 19 Mar 2012 at 9:48

GoogleCodeExporter commented 9 years ago
This issue is fixed in the 1.0 Beta 8 release of the google-api-python-client 
library. I believe by referring to 1.6.4 you are referring to the version 
number of the Google App Engine Python SDK, which has nothing to do with it.

Original comment by jcgregorio@google.com on 20 Mar 2012 at 2:06

GoogleCodeExporter commented 9 years ago
Sorry, my mistake, indeed it has nothing to do with the GAE Python SDK. Having 
said that, do you know when the GAE teams are likely to pull this fix into the 
libraries that they use?

Original comment by webmas...@jgrall.com on 28 Mar 2012 at 12:13

GoogleCodeExporter commented 9 years ago
Having the same error doing a self.redirect ... I print out the header just 
prior to exiting the request ... i even tried resaving all the header fields 
but don't understand why the content-type, cache-control, content-length are on 
a redirect -- I thought the header just needed the Location key.  

INFO     2012-04-07 07:21:58,050 common.py:886] ["FINISH HEADER", 
[("Content-Type", "text/html; charset=utf-8"), ("Cache-Control", "no-cache"), 
("Content-Length", "0"), ("Location", "http://localhost:8080/axD2MSK/home/")]]

ERROR    2012-04-07 07:21:58,050 webapp2.py:1553] header values must be str, 
got 'unicode'

Traceback (most recent call last):
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1547, in __call__
    return response(environ, start_response)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webob_1_1_1/webob/response.py", line 939, in __call__
    start_response(self.status, headerlist)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 147, in _StartResponse
    _GetTypeName(header[1]))
InvalidResponseError: header values must be str, got 'unicode'

So, I clear out the header before doing the self.redirect thinking those three 
fields were related to the problem  ... now getting the following header

INFO     2012-04-07 07:33:42,518 common.py:886] ["FINISH HEADER", 
[("Content-Length", "0"), ("Location", "http://localhost:8080/axNrlF2/home/")]]

resulted in the same error ...

then I tried this ...

        self.redirect( aUrl )
        self.response.headers[ 'Location' ] = str( aUrl )

and IT WORKED ...

Original comment by jimgill...@gmail.com on 7 Apr 2012 at 7:41