cannot import name is_secure_transport
Asked Answered
K

2

13

I am using python-social-auth API for authentication in my website. But I am getting an exception `cannot import name is_secure_transport.

Below is the trace.

Django 1.7
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'social.apps.django_app.default',
 'login')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  111.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/apps/django_app/utils.py" in wrapper
  49.                                                backend, uri)
File "/usr/local/lib/python2.7/dist-packages/social/apps/django_app/utils.py" in load_backend
  29.     Backend = get_backend(BACKENDS, name)
File "/usr/local/lib/python2.7/dist-packages/social/backends/utils.py" in get_backend
  51.         load_backends(backends, force_load=True)
File "/usr/local/lib/python2.7/dist-packages/social/backends/utils.py" in load_backends
  33.             backend = module_member(auth_backend)
File "/usr/local/lib/python2.7/dist-packages/social/utils.py" in module_member
  23.     module = import_module(mod)
File "/usr/local/lib/python2.7/dist-packages/social/utils.py" in import_module
  17.     __import__(name)
File "/usr/local/lib/python2.7/dist-packages/social/backends/facebook.py" in <module>
  12. from social.backends.oauth import BaseOAuth2
File "/usr/local/lib/python2.7/dist-packages/social/backends/oauth.py" in <module>
  4. from requests_oauthlib import OAuth1
File "/usr/local/lib/python2.7/dist-packages/requests_oauthlib/__init__.py" in <module>
  3. from .oauth2_auth import OAuth2
File "/usr/local/lib/python2.7/dist-packages/requests_oauthlib/oauth2_auth.py" in <module>
  3. from oauthlib.oauth2 import is_secure_transport

Exception Type: ImportError at /login/google-oauth2/
Exception Value: cannot import name is_secure_transport
Keewatin answered 26/9, 2014 at 3:39 Comment(6)
My guess is, you might have an older version of oauthlib Try upgrading it to 0.6.xBaillieu
thanx @Baillieu upgrading worked for me ... now getting HTTPError at /complete/google-oauth2/ 401 Client Error: Unauthorized any idea...Keewatin
make sure you have provided the correct credentials as defined in the documentationBaillieu
Having same issue. I have upgraded oauthlib to 0.6.1.Enfleurage
@ShashankHegde hope that worked for you.. :-)Keewatin
@Keewatin : Thanks it worked for me. I upgraded it to 0.7 :)Enfleurage
M
10

Updating the oauthlib version definitely works.

Just do this:

sudo pip install --upgrade oauthlib 
Miguelinamiguelita answered 3/3, 2015 at 5:50 Comment(0)
E
7

you should uninstall tweepy, upgrade oauthlib and then reinstall tweepy as root:

sudo pip uninstall tweepy
sudo pip install oauthlib --upgrade
sudo apt-get install python-tweepy

Had the same problem and this worked fine for me.

Easley answered 30/10, 2015 at 17:5 Comment(2)
This sorted me out. I recently had to upgrade tweepy because of this: https://mcmap.net/q/906185/-using-tweepy-to-search-for-tweets-with-api-1-1. Turns out I then needed to do the full overhaul to make it work. Thanks!Lemons
Having tried a few other things (including the accepted answer) this is what fixed it for meGleanings

© 2022 - 2024 — McMap. All rights reserved.