Error: Django-Social-Auth LinkedIn Client Error - django

After authentication I got this error message
HTTPError at /oauth/complete/linkedin-oauth2/
410 Client Error: Gone for url: https://api.linkedin.com/v1/people/~:(email-address,first-name,headline,id,industry,last-name)?format=json
Django settings conf
SOCIAL_AUTH_LINKEDIN_OAUTH2_SCOPE = [
'r_emailaddress',
'r_liteprofile'
]
SOCIAL_AUTH_LINKEDIN_OAUTH2_FIELD_SELECTORS = [
'email-address',
'headline',
'industry',]
======================================
Django package versions:
social-auth-app-django==3.1.0
social-auth-core==2.0.0
Django==2.1

For those wondering in May of 2019, the PyPi version is still behind what is in master on Github and is using LinkedIn's deprecated v1 API instead of the v2.
This worked for me:
pip uninstall social-auth-core
pip install git+https://github.com/python-social-auth/social-core

Related

ResolutionImpossible - Conflicting dependencies while deploying on heroku

While deploying a Django + React project on Heroku, this error occoured:
The conflict is caused by:
djoser 2.1.0 depends on social-auth-app-django<5.0.0 and >=4.0.0
rest-social-auth 8.0.0 depends on social-auth-app-django<6.0 and >=5.0
If I downgrade to social-auth-app-django==4.0.0 pkg, then get this error:
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: WSGI application 'backend.wsgi.application' could not be loaded; Error importing module.
This error is caused by social_django which is added in settings.py
MIDDLEWARE = [
....
# For social auth
'social_django.middleware.SocialAuthExceptionMiddleware',
....
]
Fixed this error by removing/commenting it out, then found another one:
cannot import name 'urlquote' from 'django.utils.http' (lib\site-packages\django\utils\http.py)
Because urlquote() is no longer available in Django 4.0+ versions, after downgrading social-auth-app-django==4.0.0
pkg.
This try to import from django.utils.http import urlquote in filelib\site-packages\social_django\context_processors.py.
I'm in Dependency hell. I have even tried to downgrading the djoser pkg, then got other errors.
After searching a lot, I found this blog post, according to this:
First, pip install pip-tools then create a requirements.in file and add
django
djangorestframework
then run pip-compile ./requirements.in this will generate requirements.txt file:
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile ./requirements.in
#
asgiref==3.6.0
# via django
django==4.1.5
# via
# -r ./requirements.in
# djangorestframework
djangorestframework==3.14.0
# via -r ./requirements.in
pytz==2022.7.1
# via djangorestframework
sqlparse==0.4.3
# via django
tzdata==2022.7
# via django
But this file doesn't contain other packages like:
django-cors-headers,
djoser,
PyJWT
rest-social-auth
social-auth-app-django,
etc....
Please help me with this question, any resource that can help me.

twisted critical unhandled error on scrapy tutorial

I'm new in programming and I'm trying to learn scrapy, using scrapy tutorial: http://doc.scrapy.org/en/latest/intro/tutorial.html
So I ran "scrapy crawl dmoz" command and got this error:
2015-07-14 16:11:02 [scrapy] INFO: Scrapy 1.0.1 started (bot: tutorial)
2015-07-14 16:11:02 [scrapy] INFO: Optional features available: ssl, http11
2015-07-14 16:11:02 [scrapy] INFO: Overridden settings: {'NEWSPIDER_MODULE': 'tu
torial.spiders', 'SPIDER_MODULES': ['tutorial.spiders'], 'BOT_NAME': 'tutorial'}
2015-07-14 16:11:05 [scrapy] INFO: Enabled extensions: CloseSpider, TelnetConsol
e, LogStats, CoreStats, SpiderState
Unhandled error in Deferred:
2015-07-14 16:11:06 [twisted] CRITICAL: Unhandled error in Deferred:
2015-07-14 16:11:07 [twisted] CRITICAL:
I'm using windows 7 and python 2.7. Anybody knows what's the problem? How could I fix that?
EDIT: My spider file code is:
# This package will contain the spiders of your Scrapy project
#
# Please refer to the documentation for information on how to create and manage
# your spiders.
import scrapy
class DmozSpider(scrapy.Spider):
name = "dmoz"
allowed_domains = ["dmoz.org"]
start_urls = [
"http://www.dmoz.org/computers/programming/languages/python/books/",
"http://www.dmoz.org/computer/programming/languages/python/resources/"
]
def parse(self, response):
filename = response.url.split("/")[-2] + '.html'
with open(filename,'wb') as f:
f.write(response.body)
items.py code:
import scrapy
class DmozItem(scrapy.Item):
title = scrapy.Field()
link = scrapy.Field()
desc = scrapy.Field()
pip list:
bootstrap-admin (0.3.3)
cffi (1.1.2)
characteristic (14.3.0)
cryptography (0.9.3)
cssselect (0.9.1)
Django (1.7.7)
django-auth-ldap (1.2.4)
django-debug-toolbar (1.3.0)
django-mssql (1.6.2)
django-pyodbc (0.2.6)
django-pyodbc-azure (1.2.2)
django-redator (0.2.3)
django-reversion (1.8.5)
django-summernote (0.6.0)
django-windows-tools (0.1.1)
django-wysiwyg-redactor (0.4.3.2)
enum34 (1.0.4)
ez-setup (0.9)
flup (1.0.2)
idna (2.0)
ipaddress (1.0.13)
iso8601 (0.1.4)
logging (0.4.9.6)
lxml (3.4.4)
mechanize (0.2.5)
MySQL-python (1.2.4)
pbr (0.10.8)
Pillow (2.7.0)
pip (7.1.0)
pyasn1 (0.1.8)
pyasn1-modules (0.0.6)
pycparser (2.14)
pymongo (2.6)
pyodbc (3.0.7)
pyOpenSSL (0.15.1)
pypm (1.4.3)
python-ldap (2.4.18)
pythonselect (1.3)
pywin32 (218.3)
queuelib (1.2.2)
Scrapy (1.0.1)
selenium (2.44.0)
service-identity (14.0.0)
setuptools (18.0.1)
six (1.9.0)
sqlparse (0.1.15)
stevedore (1.3.0)
Twisted (15.2.1)
virtualenv (1.11.6)
virtualenv-clone (0.2.5)
virtualenvwrapper (4.3.2)
virtualenvwrapper-powershell (12.7.8)
w3lib (1.11.0)
xlrd (0.9.2)
zope.interface (4.1.2)
Thx for the attention and sry for my poor English, isn't my native language.
I'm beginning to learn scrapy as well and encounter the same question with yours.
After struggling with it for an afternoon, finally I found it's due to the pywin32 module only download without install.
You can try input the command below in the cmd to finish the pywin32 module install and try crawl again:
python python27\scripts\pywin32_postinstall.py -install
I hope it will help!
The short answer is You are missing pywin32!
The other answers are basically right, but not 100% correct. pywin32 is not a pip install! You must download the installer package from here:
http://sourceforge.net/projects/pywin32/files/pywin32/
Make sure that you get the correct bit: 32 or 64. In my case I didn't realize I had the 32bit version of Python installed on my 64bit machine and the installer fails with "Cannot find Python 2.7 installation in registry". I had to install the 32bit version of pywin32. Once I did this, scrapy crawl site worked.
I dont see what your doing with items as your writing to a file. But its the imports maybe. Try this if this does not work try, pip install pywin --update and pip install Twisted --update, that should reinstall any corrupted files.
Plus I dont know if it's Stack's problem but you had some misplaced identation.
from scrapy.spiders import Spider
from {Projectname}.items import {Itemclass}
import scrapy
class DmozSpider(scrapy.Spider):
name = "dmoz"
allowed_domains = ["dmoz.org"]
start_urls = [
"http://www.dmoz.org/computers/programming/languages/python/books/",
"http://www.dmoz.org/computer/programming/languages/python/resources/"]
def parse(self, response):
filename = response.url.split("/")[-2] + '.html'
with open(filename,'wb') as f:
f.write(response.body)
Scrapy crashes with: ImportError: No module named win32api
You need to install pywin32 because of this Twisted bug.

ImportError at /admin/ No module named polls_ChoiceField.urls

Django 1.6.2
MacOSX 10.9.2
Python 2.7
I recently deleted a Django App "polls_ChoiceField" which was sitting inside another app "polls" as I was only using it to test a few things. However since i deleted it then the app it was sitting in no longer works.
I deleted the file through the pyDev package explorer. When I synced the Database it gave my the option of deleting the stale content, I selected yes.
Can anyone tell me what I have to do to get the original "polls" all running again?
Relevant Terminal output
localhost:src brendan$ python manage.py syncdb
Creating tables ...
The following content types are stale and need to be deleted:
polls | choice_choicefield
polls | poll_choicefield
Any objects related to these content types by a foreign key will also
be deleted. Are you sure you want to delete these content types?
If you're unsure, answer 'no'.
Type 'yes' to continue, or 'no' to cancel: yes
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
I then synced the DB
localhost:src brendan$ python manage.py syncdb
Creating tables ...
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
And I am able to run the server
localhost:src brendan$ python manage.py runserver
Validating models...
0 errors found
When i try to revisit the app in my browser i get
ImportError at /polls/
No module named polls_ChoiceField.urls
Request Method: GET
Request URL: http://localhost:8000/polls/
Django Version: 1.6.2
Exception Type: ImportError
Exception Value:
No module named polls_ChoiceField.urls
Exception Location: /Library/Python/2.7/site-packages/django/utils/importlib.py in import_module, line 40
Python Executable: /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Python Version: 2.7.6
Python Path:
['/Users/brendan/Dropbox/workspace/bias_experiment/src',
'/Library/Python/2.7/site-packages/distribute-0.7.3-py2.7.egg',
'/Library/Python/2.7/site-packages/setuptools-2.2-py2.7.egg',
'/Library/Python/2.7/site-packages/pip-1.5.4-py2.7.egg',
'/Library/Python/2.7/site-packages/yolk-0.4.3-py2.7.egg',
'/Library/Python/2.7/site-packages/virtualenv-1.11.4-py2.7.egg',
'/Library/Python/2.7/site-packages/virtualenvwrapper-4.2-py2.7.egg',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages',
'/Library/Python/2.7/site-packages']
Server time: Mon, 28 Apr 2014 16:26:46 +0100
Thanks
EDIT:
My urls.py with the bad line of code (the middle url)
urlpatterns = patterns('',
url(r'^polls/', include('polls.urls', namespace="polls")),
url(r'^polls_ChoiceField/', include('polls_ChoiceField.urls', namespace="polls_ChoiceField")),
url(r'^admin/', include(admin.site.urls)),
)
Thanks again.
Check your project-level urls.py, looks like it still tries to use urls from the deleted app.

Django ViewDoesNotExist error after installing photologue

I'm using Django 1.5.1. Everything was OK. But as soon as I installed django-photologue through pip I face this error when I visit admin url:
> **ViewDoesNotExist at /admin/**
Could not import django.views.generic.list_detail.object_list. Parent module django.views.generic.list_detail does not exist.
Request Method: GET
Request URL: http://localhost:8000/admin/
Django Version: 1.5.1
Exception Type: ViewDoesNotExist
Exception Value:
Could not import django.views.generic.list_detail.object_list. Parent module django.views.generic.list_detail does not exist.
Exception Location: /usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py in get_callable, line 104
Python Executable: /usr/bin/python
Python Version: 2.7.3
Also when I run syncdb, photologue sync with database without any error and I can import it in shell.
Any idea about how can I solve this error?
to replace the file in the directory urls.py photologue :
"django.views.generic.date_based" and "django.views.generic.list_detail" on "django.views.generic"
"object_list" on "list.ListView"
"object_detail" on "detail.DetailView"
"archive_year" on "dates.YearArchiveView"
"archive_month" on "dates.MonthArchiveView"
"archive_day" on "dates.DayArchiveView"
like this :)
or read :
django-photologue was most likely built for an older version of Django. Looks like the newer version of Django isn't friendly with generic views and prefers class based views instead.
Downloading a fresh copy of Django 1.5.1 shows the following:
http://f.cl.ly/items/0k1J261S2J2f3k3C110I/Image%202013.04.20%203%3A44%3A39%20AM.png
Whereas Django 1.4.2 shows:
http://f.cl.ly/items/152J2U050X0z1j1n0v0D/Image%202013.04.20%203%3A46%3A49%20AM.png
Simply put, the newer version of Django removed the list_detail file.

Django-cms 2.3 - 'cms_tags' is not a valid tag library

I'm trying to update my Django-cms from version 2.2 to 2.3 and when I try to "runserver", I get this error:
django.template.base.TemplateSyntaxError: 'cms_tags' is not a valid tag library: ImportError raised loading cms.templatetags.cms_tags: cannot import name VersionAdapter
The installation of django-cms=2.3 worked perfectly, but there is something somewhere broking everything.
Here's a list of what's installed on this virtualenv:
BeautifulSoup==3.2.0
Django==1.3.1
Fabric==1.4.3
MySQL-python==1.2.3
PIL==1.1.7
South==0.7.3
argparse==1.2.1
cmsplugin-filer==0.8.0
django-admin-tools==0.4.0
-e git://github.com/bmihelac/django-app-name-translation-in- admin.git#c7b033bdfb54fee5217248f4e596aa23752185e0#egg=django_app_name_translation_in_admin-dev
django-appconf==0.4.1
django-classy-tags==0.3.4.1
django-cms==2.3
django-debug-toolbar==0.8.5
django-filer==0.8.5
-e git+https://github.com/toastdriven/django-haystack.git#d2b51143c8008be8523a78822002de1836b9f501#egg=django_haystack-dev
django-hvad==0.1.5
django-mptt==0.5.1
django-page-cms==1.4.5
django-permissions==1.0.3
django-reversion==1.4
django-sekizai==0.5
django-staticfiles==1.1.2
django-transmeta==0.6.2
easy-thumbnails==1.0-alpha-18
feedparser==5.0.1
html5lib==0.90
httplib2==0.7.2
ipython==0.11
poster==0.8.1
pycrypto==2.6
pysolr==2.1.0-beta
python-ptrace==0.6.4
simplejson==2.2.1
sorl-thumbnail==11.09
ssh==1.7.14
virtualenv==1.6.4
wsgiref==0.1.2
Anyone have an idea ?
VersionAdapter belongs to django-reversion so you need need to upgrade (django-reversion) to version 1.6. See the django-cms installation notes:
http://docs.django-cms.org/en/2.3.3/getting_started/installation.html