Testing flask-oauthlib locally without https

From http://requests-oauthlib.readthedocs.org/en/latest/examples/real_world_example.html:

You should note that Oauth2 works through SSL layer. If your server is
not parametrized to allow HTTPS, the fetch_token method will raise an
oauthlib.oauth2.rfc6749.errors.InsecureTransportError . Most people
don’t set SSL on their server while testing and that is fine. You can
disable this check in two ways:

  1. By setting an environment variable.
export OAUTHLIB_INSECURE_TRANSPORT=1
  1. Equivalent to above you can set this in Python (if you have problems setting environment variables)
# Somewhere in webapp_example.py, before the app.run for example
import os 
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'

Leave a Comment