Error With Stripe Calls On Google App Engine Even After Upgrading To Latest
Solution 1:
Does your appengine_config.py
have this in it yet?
import os
from google.appengine.ext import vendor
from google.appengine.ext.appstats import recording
appstats_CALC_RPC_COSTS = True# Add any libraries installed in the "lib" folder.
vendor.add('lib')
defwebapp_add_wsgi_middleware(app):
app = recording.appstats_wsgi_middleware(app)
return app
# if on localhostif os.environ.get('SERVER_SOFTWARE', '').startswith('Development'):
import imp
import os.path
import inspect
from google.appengine.tools.devappserver2.python import sandbox
sandbox._WHITE_LIST_C_MODULES += ['_ssl', '_socket']
# Use the system socket.
real_os_src_path = os.path.realpath(inspect.getsourcefile(os))
psocket = os.path.join(os.path.dirname(real_os_src_path), 'socket.py')
imp.load_source('socket', psocket)
else:
# Doing this on dev_appserver/localhost seems to cause outbound https requests to failfrom lib import requests
from lib.requests_toolbelt.adapters import appengine as requests_toolbelt_appengine
# Use the App Engine Requests adapter. This makes sure that Requests uses# URLFetch.
requests_toolbelt_appengine.monkeypatch()
I copied my whole file because I'm not sure which parts you already have, but the key part is that final if-else. I went through a whole mess of trouble getting TLS 1.2 working on prod, which primarily came down to specifying version 2.7.11
for App Engine's special ssl library & requests_toolbelt_appengine.monkeypatch()
.
Like you this broke ssl on localhost for me, so now I only do requests_toolbelt_appengine.monkeypatch()
on prod, and on localhost I do that 'white-listing the native sockets library' trick you've probably seen. Part of this comes down what combination of versions of things you're using. Hopefully this helps.
Notable items from my app.yaml
:
env_variables:theme:'default'GAE_USE_SOCKETS_HTTPLIB :'true'# TLS 1.2libraries:-name:jinja2version:"2.6"-name:webapp2version:"2.5.2"-name:markupsafeversion:"0.15"-name:sslversion:"2.7.11"# TLS 1.2-name:pycryptoversion:"2.6"-name:lxmlversion:latest
Also I'm using python-requests 2.18.2
EDIT:
In my ~/.bash_profile
, google cloud sdk was added to my path:
export PATH="/Users/alex/google-cloud-sdk/platform/google_appengine/:$PATH"
.
If I go to that folder, I can follow the imports for from google.appengine.tools.devappserver2.python import sandbox
all the way through. (screenshot included below)
Post a Comment for "Error With Stripe Calls On Google App Engine Even After Upgrading To Latest"