Send_email with django generate error _getfullpathname: - python

i'm tring to send email with django but i recive ad error even with a easy code
send_mail(
'Subject here',
'Here is the message.',
'from#example.com',
['to#example.com'],
fail_silently=False,
)
i get that output error
Traceback (most recent call last):
File "D:\VisualStudioWorkspaces\DjangoPlayground\.venv\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "D:\VisualStudioWorkspaces\DjangoPlayground\.venv\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "D:\VisualStudioWorkspaces\DjangoPlayground\django_tutorial\accounts\views.py", line 93, in register
send_mail(
File "D:\VisualStudioWorkspaces\DjangoPlayground\.venv\lib\site-packages\django\core\mail\__init__.py", line 52, in send_mail
connection = connection or get_connection(
File "D:\VisualStudioWorkspaces\DjangoPlayground\.venv\lib\site-packages\django\core\mail\__init__.py", line 35, in get_connection
return klass(fail_silently=fail_silently, **kwds)
File "D:\VisualStudioWorkspaces\DjangoPlayground\.venv\lib\site-packages\django\core\mail\backends\filebased.py", line 20, in __init__
self.file_path = os.path.abspath(self.file_path)
File "C:\Users\oscur\AppData\Local\Programs\Python\Python39\lib\ntpath.py", line 527, in abspath
return normpath(_getfullpathname(path))
Exception Type: TypeError at /accounts/registration/
Exception Value: _getfullpathname: path should be string, bytes or os.PathLike, not NoneType

Django support different email backends.
SMTP backend(Default)
Console backend
File backend
In-memory backend
When you use send_mail function without a backend argument django select backend based on settings.EMAIL_BACKEND.
From the exception it seems like django using File backend(Which means EMAIL_BACKEND you are using most likely 'django.core.mail.backends.filebased.EmailBackend')
Quoting from the django docs
The file backend writes emails to a file. A new file is created for
each new session that is opened on this backend. The directory to
which the files are written is either taken from the EMAIL_FILE_PATH
setting or from the file_path keyword when creating a connection with
get_connection().
So my suggestion is that setting EMAIL_FILE_PATH in settings.py will solve this issue.

Related

My GitLab server response with 500 Error but still recieves and uploads files that are sent

So I have very strange problem. I am working on this application that is using GitLab instance (version: 15.5.1) on my server in background with CentOS. I am using API, python-gitlab library and my Flask app. I was was making little change to my function which was adding bas64 decoder before this everything worked just fine. So after this change I send one request with Postman to see if it works.
And this is where the problem starts functions works it decodes base64 and sends it to server where it is saved in repo. BUT serevr response with 500 INTERNAL SERVER ERROR in Postman.
ERROR FROM TERMINAL:
[2023-02-17 10:07:45,597] ERROR in app: Exception on /data [POST]
Traceback (most recent call last):
File "exceptions.py", line 337, in wrapped_f
return f(*args, **kwargs)
File "mixins.py", line 246, in list
obj = self.gitlab.http_list(path, **data)
File "client.py", line 939, in http_list
return list(GitlabList(self, url, query_data, **kwargs))
File "client.py", line 1231, in __next__
return self.next()
File "client.py", line 1242, in next
self._query(self._next_url, **self._kwargs)
File "/client.py", line 1154, in _query
result = self._gl.http_request("get", url, query_data=query_data, **kwargs)
File "client.py", line 798, in http_request
raise gitlab.exceptions.GitlabHttpError(
gitlab.exceptions.GitlabHttpError: 404: HERE STARTS LONG HTML FILE
MY FUNCTION: type and text are JSON parameter JSON file is below this code
def pushFile(type, text):
decoded_text = base64.b64decode(text)
project_id = config.REPO_ID
project = gl.projects.get(project_id)
#RANDOM ID
uni_id = uuid.uuid1()
f = project.files.create({'file_path': f'{compared_type}'+'_RULES/'+f'{type}'+'_'+f'{uni_id}'+'.txt',
'branch': 'main',
'content': f'{decoded_text}',
'author_email': 'test#example.com',
'author_name': 'yourname',
'commit_message': 'Create testfile'})
JSON:
{
"type" :"radar",
"text" : "dGVzdHRlc3R0ZXN0dGVzdHRlc3R0ZXN0dGVzdHRlc3R0ZXN0dGVzdHRlc3R0ZXN0dGVzdHRlc3R0ZXN0dGVzdHRlc3R0ZXN0dGVzdHRlc3R0ZXN0dGVzdA=="
}
So I tried to:
Restart GitLab instance
Delete bas64 decoder
But nothing helped and I still get 500 error but files are still uploaded. Does someone have any idea what might be wrong?

Spotipy Token Caching with Django

I am trying to host an app which utilizes the Spotipy library to create and add songs to user's Spotify accounts. The app works fine on my local as the authorization token is stored in the root folder and when prompted on my terminal I am able to "Enter the URL you were redirected to:". I'm using Pythonanywhere to host the app and can see in the server log that the same question is asked but obviously Ito no answer. I've been reading about Django Sessions to try and cache user's tokens but am a bit lost and the only example in the documentation is for Flask.
The code I am using is below - happy to share more from additional files if needed, any help is greatly appreciated!
The function that creates a new playlist and adds songs to it is triggered when a form is submitted which contains the user's Spotify Username and the 'group' object which is later used to name the playlist...
def AggregateTopsList(group, queryset, spotify_user_id, song_limit, start_date, end_date):
2. imports...
import spotipy
from spotipy.oauth2 import SpotifyOAuth
from spotipy.oauth2 import SpotifyClientCredentials
import pandas as pd
3. Spotify API Authentication - client credentials (redirect URI, client ID & client secret) are stored as environment variables. I assume this is where I'll need to implement something to cache users tokens…
scope="playlist-modify-public"
spotify = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))
<code to determine which songs to add to the playlist, which creates a list of track IDs in a variable called 'songs'>
4. Using the Spotipy library to - create a new playlist, determine the ID of that new playlist and add songs to it. Assume this is when my terminal prompts me to enter the redirect URL that pops up
'''create new playlist'''
createnewplaylist = sp.user_playlist_create(spotify_user_id, group.name, public=True, collaborative=False, description='test')
'''determine ID of newly created playlist'''
newplaylistinfo = sp.user_playlists(spotify_user_id)
playlist_id = newplaylistinfo['items'][0]['id']
'''add 'songs' to new playlist'''
add_tracks = sp.playlist_add_items(playlist_id, songs, position=None)
Here is the error within Pythonanywhere:
2022-10-18 00:58:37,526: User authentication requires interaction with your web browser. Once you enter your credentials and give authorization, you will be redirected to a url. Paste that url you were directed to to complete the authorization. 2022-10-18 00:58:37,626: Opened https://accounts.spotify.com/authorize?client_id=ef35ce3c64be47769869fa2cb401798e&response_type=code&redirect_uri=http%3A%2F%2Ftopsnight.pythonanywhere.com%2F&scope=playlist-modify-public in your browser 2022-10-18 00:58:38,123: Internal Server Error: /TopsList/Group/11/aggregate Traceback (most recent call last): File "/home/topsnight/.virtualenvs/topsnightenv/lib/python3.9/site-packages/spotipy/oauth2.py", line 115, in _get_user_input return raw_input(prompt) NameError: name 'raw_input' is not defined NO MATCH During handling of the above exception, another exception occurred: NO MATCH Traceback (most recent call last): File "/home/topsnight/.virtualenvs/topsnightenv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "/home/topsnight/.virtualenvs/topsnightenv/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/topsnight/.virtualenvs/topsnightenv/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view return view_func(request, *args, **kwargs) File "/home/topsnight/topsnight/./TopsListGenerator/views.py", line 238, in aggregategroup topslist = AggregateTopsList(agggroup, aggplaylists, song_limit, spotify_user_id, start_date, end_date) File "/home/topsnight/topsnight/./TopsListGenerator/functions.py", line 104, in AggregateTopsList createnewplaylist = sp.user_playlist_create(spotify_user_id, group.name, public=True, collaborative=False, description='test') File "/home/topsnight/.virtualenvs/topsnightenv/lib/python3.9/site-packages/spotipy/client.py", line 784, in user_playlist_create return self._post("users/%s/playlists" % (user,), payload=data) File "/home/topsnight/.virtualenvs/topsnightenv/lib/python3.9/site-packages/spotipy/client.py", line 302, in _post return self._internal_call("POST", url, payload, kwargs) File "/home/topsnight/.virtualenvs/topsnightenv/lib/python3.9/site-packages/spotipy/client.py", line 221, in _internal_call headers = self._auth_headers() File "/home/topsnight/.virtualenvs/topsnightenv/lib/python3.9/site-packages/spotipy/client.py", line 212, in _auth_headers token = self.auth_manager.get_access_token(as_dict=False) File "/home/topsnight/.virtualenvs/topsnightenv/lib/python3.9/site-packages/spotipy/oauth2.py", line 535, in get_access_token "code": code or self.get_auth_response(), File "/home/topsnight/.virtualenvs/topsnightenv/lib/python3.9/site-packages/spotipy/oauth2.py", line 499, in get_auth_response return self._get_auth_response_interactive(open_browser=open_browser) File "/home/topsnight/.virtualenvs/topsnightenv/lib/python3.9/site-packages/spotipy/oauth2.py", line 450, in _get_auth_response_interactive response = self._get_user_input(prompt) File "/home/topsnight/.virtualenvs/topsnightenv/lib/python3.9/site-packages/spotipy/oauth2.py", line 117, in _get_user_input return input(prompt) EOFError: EOF when reading a line

Spotipy: How to pass the auth token to the client

I'm trying to build an app using the spotipy python library to access the spotify api.
My oauth code looks like this and it seems to work except for initialising the client with the right auth parameter.
self.sp_auth=spotipy.oauth2.SpotifyOAuth(secrets.sp_auth_id,
secrets.sp_auth_pw, secrets.sp_callback_url,
scope="playlist-modify-public user-library-read", state=state)
...
url = self.sp_auth.get_authorize_url()
send url to user.
after user said she/he has given permission:
auth code is fetched from webserver and used to generate a token.
self.auth_token=self.sp_auth.get_access_token(self.auth_code)
self.auth_token then looks like this:
{'access_token' : 'BQD ... qE7K3PBZKB6iZFU3_4p',
'token_type' : 'Bearer',
'expires_in' : 3600,
'refresh_token' : 'AQCOS2Xo ... MK09ry7-a-fl61OwhuO1Q',
'scope' : 'playlist-modify-public user-library-read',
'expires_at' : 1548247835}
then I initialize the spotipy client module like this:
self.sp = spotipy.Spotify(auth=self.auth_token)
then I try the following:
playlists = self.sp.current_user_playlists(limit=10)
which raises this Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/spotipy/client.py", line 119, in _internal_call
r.raise_for_status()
File "/usr/local/lib/python3.6/dist-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.spotify.com/v1/me/playlists?limit=10&offset=0
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/telegram/ext/dispatcher.py", line 279, in process_update
handler.handle_update(update, self)
File "/usr/local/lib/python3.6/dist-packages/telegram/ext/callbackqueryhandler.py", line 143, in handle_update
return self.callback(dispatcher.bot, update, **optional_args)
File "spotify_playlist_bot_v2.py", line 140, in button_auth_done
User.data[user_id].msg_start(bot, update)
File "spotify_playlist_bot_v2.py", line 84, in msg_start
self.msg_choose_playlist()
File "spotify_playlist_bot_v2.py", line 90, in msg_choose_playlist
playlists = self.sp.current_user_playlists(limit=10)
File "/usr/local/lib/python3.6/dist-packages/spotipy/client.py", line 355, in current_user_playlists
return self._get("me/playlists", limit=limit, offset=offset)
File "/usr/local/lib/python3.6/dist-packages/spotipy/client.py", line 146, in _get
return self._internal_call('GET', url, payload, kwargs)
File "/usr/local/lib/python3.6/dist-packages/spotipy/client.py", line 124, in _internal_call
headers=r.headers)
spotipy.client.SpotifyException: http status: 400, code:-1 - https://api.spotify.com/v1/me/playlists?limit=10&offset=0:
Only valid bearer authentication supported
It looks like I'm not passing the token to the spotipy client correctly. For example self.sp = spotipy.Spotify(auth="random_bullshit") gives me the same Exception. I also tried passing the token like this auth=self.auth_token['access_token'] with the same result. The documentation doesn't say anything about what the auth parameter should be exactly and I'm not really understanding the source code. But I'd say it suggests that auth=self.auth_token['access_token'] is the right thing to do.
Thanks!
As I already suggested in my last edit auth=self.auth_token['access_token'] was the right thing I just had a typo in it. Anyway since the Documentation doesn't say a lot about the auth parameter this might help some people.

Asynchronious email sending in Django

I'm trying to figure out how to send email asynchroniously so User don't have to wait until email is sent.
I've installer celery and django-celery-email and added django-celery-email into my settings.py - djcelery_email.
I've also changed database backend:
EMAIL_BACKEND = 'djcelery_email.backends.CeleryEmailBackend'
Now I've tried to do an action which sends email but it freezes and no email has been sent.
Do you know what to do?
Here is a traceback from cmd:
Internal Server Error: /ajax/reservation/confirm/
Traceback (most recent call last):
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\django\core\handlers\base.py", line 149, in get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\django\core\handlers\base.py", line 147, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\django\views\decorators\csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\dolava_app\views.py", line 68, in reservation_confirm
reservation.save()
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\dolava_app\models.py", line 150, in save
notifications.AdminNotifications.new_pair(self, paired_reservation)
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\dolava_app\notifications.py", line 79, in new_pair
send_message_to_admin(subject,message)
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\dolava_app\notifications.py", line 8, in send_message_to_admin
mail.send()
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\django\core\mail\message.py", line 292, in send
return self.get_connection(fail_silently).send_messages([self])
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\djcelery_email\backends.py", line 17, in send_messages
result_tasks.append(send_emails.delay(chunk, self.init_kwargs))
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\celery\app\task.py", line 453, in delay
return self.apply_async(args, kwargs)
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\celery\app\task.py", line 565, in apply_async
**dict(self._get_exec_options(), **options)
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\celery\app\base.py", line 354, in send_task
reply_to=reply_to or self.oid, **options
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\celery\app\amqp.py", line 310, in publish_task
**kwargs
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\kombu\messaging.py", line 172, in publish
routing_key, mandatory, immediate, exchange, declare)
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\kombu\connection.py", line 457, in _ensured
interval_max)
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\kombu\connection.py", line 369, in ensure_connection
interval_start, interval_step, interval_max, callback)
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\kombu\utils\__init__.py", line 246, in retry_over_time
return fun(*args, **kwargs)
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\kombu\connection.py", line 237, in connect
return self.connection
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\kombu\connection.py", line 742, in connection
self._connection = self._establish_connection()
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\kombu\connection.py", line 697, in _establish_connection
conn = self.transport.establish_connection()
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\kombu\transport\pyamqp.py", line 116, in establish_connection
conn = self.Connection(**opts)
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\amqp\connection.py", line 165, in __init__
self.transport = self.Transport(host, connect_timeout, ssl)
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\amqp\connection.py", line 186, in Transport
return create_transport(host, connect_timeout, ssl)
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\amqp\transport.py", line 299, in create_transport
return TCPTransport(host, connect_timeout)
File "C:\Users\Milano\PycharmProjects\FutileStudio\dolava\venv\lib\site-packages\amqp\transport.py", line 95, in __init__
raise socket.error(last_err)
error: [Errno 10061] No connection could be made because the target machine actively refused it
Problem
From https://github.com/pmclanahan/django-celery-email
By default django-celery-email will use Django's builtin SMTP email
backend for the actual sending of the mail.
This means you need to run an SMTP server locally to accept the email. That is why you are getting a socket error - cause you don't have any SMTP server set to receive the email.
Possible Solutions - Local Development
A. Start an SMTP server and use your own client
Option 1
Run a combined SMTP server and client.
Mailcatcher is great for this.
It even comes with django setup instructions!
Set it up then fire it up with:
$ mailcatcher -fv
Note: mailcatcher requires gem (ruby package manager) to install.
So you will have to install that first.
Its probably worth the effort, as mailcatcher works quite nicely and
gives you html and text representations of the email in a browser tab.
For docker users you can get a mailcatcher docker image
Option 2
Run your own SMTP server and a separate mail client.
e.g. Use a simple python SMTP server
From the command line
python -m smtpd -n -c DebuggingServer localhost:1025
in your django settings:
EMAIL_HOST = 'localhost'
EMAIL_HOST_USER = None
EMAIL_HOST_PASSWORD = None
EMAIL_PORT = 1025
EMAIL_USE_TLS = False
Then you will need to setup a client to get those emails.
B. Don't use SMTP as a backend in your settings
Instead print to the console:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
Problem with this is ugly formatting.
HTML will appear as text which makes the email very hard to read. You can output this to a file by manually copying and pasting it into a .html file and opening it in a browser, but that will get boring very fast.
Solution - Continuous Integration Server
Use this for making email accessible to the django test client, so you can check that emails got sent, check the content of email programatically etc.
EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
Solution - Production Server
You will need to use a SMTP server again.
Either you can run your own or use Sendgrid, Mailgun, Mandrill or something similar.

django allauth social authentication retrieved email matches an existing user's email?

This is my first post in Stack exchange, I am Python and Django Noob trying to develop an application. The application uses django-registration for user registration and then I started plugging in 'social' authentication. I chose allauth as it has the ability to perform authentication among'st other things.
I have hit the same problem that was presented in this thread: django allauth facebook redirects to signup when retrieved email matches an existing user's email?
user login/signup failing if the user with same email address already exists in the database(due to registration with local registration path). I tried the solution provided in the above post and have issues. Looking for some help and advise here.
I have exactly the same code as above in my socialadapter.py under the following path
myproject/allauth/socialaccount/socialadapter.py
I have the following in my settings
LOGIN_URL = '/'
#LOGIN_REDIRECT_URL = '/'
LOGIN_REDIRECT_URL = "/users/{id}/mytags"
SOCIALACCOUNT_QUERY_EMAIL = True
ACCOUNT_AUTHENTICATION_METHOD='username_email'
SOCIALACCOUNT_EMAIL_REQUIRED = False
#create and use specific adapter to handle the issue reported here
# https://github.com/pennersr/django-allauth/issues/418
ACCOUNT_ADAPTER = "myproject.allauth.socialaccount.MyLoginAccountAdapter"
SOCIALACCOUNT_ADAPTER = 'myproject.allauth.socialaccount.MySocialAccountAdapter'
On starting the runserver and accessing the facebook/login , I see the following issue
[17/Jul/2014 11:49:43] "GET /myproject/accounts2/facebook/login/ HTTP/1.1" 500 59
---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 58805) Traceback (most recent call last): File "C:\Python27\Lib\SocketServer.py", line 593, in process_request_thread
self.finish_request(request, client_address) File "C:\Python27\Lib\SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self) File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 139, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs) File "C:\Python27\Lib\SocketServer.py", line 651, in __init__
self.finish() File "C:\Python27\Lib\SocketServer.py", line 710, in finish
self.wfile.close() File "C:\Python27\Lib\socket.py", line 279, in close
self.flush() File "C:\Python27\Lib\socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [Errno 10053] An established connection was aborted by the software in your host machine
---------------------------------------- ERROR:django.request:Internal Server Error: /myproject/accounts2/facebook/login/callback/ Traceback (most recent call last): File "C:\Python27\lib\site-packages\django\core\handlers\base.py", line 109, in get_response
response = callback(request, *callback_args, **callback_kwargs) File "myproject\allauth\socialaccount\providers\oauth2\views.py", line 51, in view
return self.dispatch(request, *args, **kwargs) File "myproject\allauth\socialaccount\providers\oauth2\views.py", line 98, in dispatch
response=access_token) File "myproject\allauth\socialaccount\providers\facebook\views.py", line 43, in complete_login
return fb_complete_login(request, app, access_token) File "myproject\allauth\socialaccount\providers\facebook\views.py", line 31, in fb_complete_login
.sociallogin_from_response(request, extra_data) File "myproject\allauth\socialaccount\providers\base.py", line 44, in sociallogin_from_response
adapter = get_adapter() File "myproject\allauth\socialaccount\adapter.py", line 150, in get_adapter
return import_attribute(app_settings.ADAPTER)() File "myproject\allauth\utils.py", line 97, in import_attribute
ret = getattr(importlib.import_module(pkg), attr) AttributeError: 'module' object has no attribute 'MySocialAccountAdapter' [17/Jul/2014 11:49:46] "GET /myproject/accounts2/facebook/login/callback/?code=AQBShGWTHnGVvlo-fOVW7xjF9RUJo-k7P23zISHC70p aAR5uWYpnI46gpHFUCC5Rz-SviDyTITVRAUkZ-DhkZaHyBT2n5UBhhSwkACgCKTTgPrFLAZFBQs05AEZ67xfk-wRlF47DSjT26bbDdUmc1ptfFxP3W4qS5Y6b5Yrj iLTI3RMScOEM0EKUQjNySyj4XSAVk6wj4HcAbCVxiVv5QaH63ayxyt5Y5jQ0AOH3zsCngPaqFNJArXseMS6wfqSc8yDwcwWZKo1nGhcNtA9Gy_bqZNiTZSjPJguhT lBwbmDAJ9SUNI8AS3yzC-AKDtD2_bo&state=441rn77wUuLH HTTP/1.1" 500 147978
Initially the socialadapter.py would not even compile,all others did compile even after deleting the .pyc
I referred to this thread: pycompile for python3.2
and force compile but I still see the issue
Any suggestions on what I might be doing wrong here is greatly appreciated.
thank you for your valuable time.
-km
EDIT:
Environment
Python 2.7.5
allauth: 0.17
Ok I figured out the issue , I had the settings entry for my adapter missing a the full path to the class. Now I am able to login using Facebook.
However I have another issue, I am trying to enable Linked in login for the same app and have the following entries in the settings
SOCIALACCOUNT_PROVIDERS = \
{'linkedin':{'SCOPE': [ 'r_emailaddress',
'r_fullprofile',
'r_emailaddress',
'r_contactinfo',
'r_network'],
'PROFILE_FIELDS':
[
'id',
'first-name',
'last-name',
'email-address',
'picture-url',
'public-profile-url',
'skills',
'headline',
'industry',
'num-connections',
'positions',
'interests',
'languages',
'certifications',
'educations',
'courses',
'three-current-positions',
'three-past-positions',
'recommendations-received',
'honors-awards'
]
},
'facebook': {'SCOPE': ['email', 'user_about_me', 'user_birthday',
'user_education_history','user_work_history',
'user_hometown',
'user_location',
'user_religion_politics','user_subscriptions',
'read_stream',
'read_insights',
'read_friendlists',
'user_likes',
'user_interests',
'user_groups'
],
'AUTH_PARAMS': {},
'METHOD': 'oauth2'
},
}
Now When I use the login page, I get the following error
[17/Jul/2014 22:26:28] "GET /myproject/accounts2/linkedin/login/?process=connect HTTP/1.1" 302 0
ERROR:django.request:Internal Server Error: /myproject/accounts2/linkedin/login/callback/
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\core\handlers\base.py", line 109, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "myproject\allauth\socialaccount\providers\oauth\views.py", line 35, in view
return self.dispatch(request, *args, **kwargs)
File "myproject\allauth\socialaccount\providers\oauth\views.py", line 90, in dispatch
return complete_social_login(request, login)
File "myproject\allauth\socialaccount\helpers.py", line 113, in complete_social_login
sociallogin=sociallogin)
File "C:\Python27\lib\site-packages\django\dispatch\dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
File "myproject\allauth\socialaccount\socialadapter.py", line 50, in link_to_local_user
email_address = sociallogin.account.extra_data['email']
KeyError: 'email'
[17/Jul/2014 22:26:50] "GET /myproject/accounts2/linkedin/login/callback/?oauth_token=77--d223fb8b-168f-4260-b93c-1a6e5ff2
e1e1&oauth_verifier=52724 HTTP/1.1" 500 139897
I am not sure how to fix this because the SCOPE for LinkedIn has : 'email-address', how can I fix this issue as the Email Fields in LinkedIn Documentation also says email-address
LinkedIn fields
Any suggestions are appreciated.
I am sorry I do not know how to put a bounty on the question and I do not have enough to place for the question also.
TIA
-km

Categories

Resources