ile birlikte, benim sorunum Pyramid on App Engine gets "InvalidResponseError: header values must be str, got 'unicode' ve birkaç google-api-python-client bugs sorusuna benzer, ancak benim durumumda hiçbiri yardımcı olmadı. Ayrıca, kendisi #111 benzer issue #254 üzerinde hiçbir cevap (vardı, bu yüzden burada çalışıyorum.oauth2client/appengine.py, "InvalidResponseError: header değerlerinin str olması," unicode "olması gerekir" webapp2/python27/wsgi
yerel GAE günü, aşağıdaki basit örneği (this sample basitleştirilmiş & python27 ified versiyon) InvalidResponseError: header values must be str, got 'unicode'
döndürür . benim kod herhangi unicode başlığı ayarını yapıyor değil olsa Daha doğrusu, ben sonuç Hello
bekliyorum ve bunun yerine var:?
Internal Server Error
The server has either erred or is incapable of performing the requested operation.
Traceback (most recent call last):
File "/home/ronj/.gae/lib/webapp2-2.5.2/webapp2.py", line 1546, in __call__
return response(environ, start_response)
File "/home/ronj/.gae/lib/webob_0_9/webob/__init__.py", line 2000, in __call__
start_response(self.status, self.headerlist)
File "/home/ronj/.gae/google/appengine/runtime/wsgi.py", line 156, in _StartResponse
(_GetTypeName(value), value, name))
InvalidResponseError: header values must be str, got 'unicode' (u'https://accounts.google.com/o/oauth2/auth?state=http%3A%2F%2Flocalhost%3A8080%2F&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Foauth2callback&response_type=code&client_id=xxxxxxxxxxxx.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube&access_type=offline') for 'Location'
herhangi bir fikir Python 2.7.3 üzerinde Gae 1.7.5 kullanıyorum Ubuntu 12.10 x64,
EDIT: Jonas, issue #254: numaralı telefona bir yanıt verdi: "URL'ler üreten OAuth2WebServerFlow öğesindeki yöntemlere bir str() eklemek nispeten kolay olmalıdır. 8a satırında geri dönmeden önce str() ile sarın oauth2client/client.py ".
→ Bu harika görünüyor, ancak bunu nasıl uygulayacağım? Yüklediğim yerel makinemde dosyayı değiştirebileceğimi kabul ediyorum GAE'nin, ama bir kez yardımınız için
Teşekkür? Ben geçersiz nasıl? doğru, kullanılan olacağını Google'ın GAE'nin olacak konuşlandırılmış (ve acemi soru için üzgünüm)!
app. yaml:
application: yourapp
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url:/
script: yourapp.main
libraries:
- name: webapp2
version: latest
yourapp.py: Ben görünüşte yapılmamalıdır piton API, Gae en paketlenmiş versiyonunu kullanıyordum
import webapp2, os, httplib2
from apiclient.discovery import build
from oauth2client.appengine import oauth2decorator_from_clientsecrets
from google.appengine.api import memcache
CLIENT_SECRETS = os.path.join(os.path.dirname(__file__), 'client_secrets.json')
MISSING_CLIENT_SECRETS_MESSAGE = "Warning: Please configure OAuth 2.0"
YOUTUBE_READ_WRITE_SCOPE = "https://www.googleapis.com/auth/youtube"
YOUTUBE_API_SERVICE_NAME = "youtube"
YOUTUBE_API_VERSION = "v3"
http = httplib2.Http(memcache)
youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION, http=http)
decorator = oauth2decorator_from_clientsecrets(
CLIENT_SECRETS,
scope=YOUTUBE_READ_WRITE_SCOPE,
message=MISSING_CLIENT_SECRETS_MESSAGE)
class MainPage(webapp2.RequestHandler):
@decorator.oauth_required
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello')
main = webapp2.WSGIApplication([('/', MainPage)], debug=True)
Jonas bir yanıt sağladı [konu # 254] (http://code.google.com/p/google-api -python-client/issues/detail? id = 254): * "URL'leri üreten OAuth2WebServerFlow'daki bazı str() yöntemlerini eklemek nispeten kolaydır. Stem() ile oauth2client/client 830 satırında dönmeden önce sarın. * ".py. Bu harika görünüyor, ama bunu nasıl uygulamalıyım? GAE'yi yüklediğim yerel makinemde dosyayı değiştirebileceğimi kabul ediyorum, ancak dağıtıldıktan sonra Google'ın kullanılacak GAE'si olacak, değil mi? Nasıl geçersiz kılabilirim? (ve yeni kullanıcı sorusu için üzgünüm) –