Obtaining user's email id even if email is not verified - python

I am working on an application using Django/Python.
I am implementing Twitch Connect and I need email address of the user for my application.
My problem is that if the user has verified email id, i obtain it as apart of the django social auth pipeline in "details" argument.
However, if the user has not verified his/her email, 'email' key does not exist in details.
Is there any way I can ensure that email always flows through?
Thank you!

Twitch does not pass through unverified emails with a user's information. It's a valid API design choice.

Related

Django-allauth - is there a way to automatically send an email after account is verified

We recently took over a project that was developed in Django, which uses allauth. We are hoping to send out some additional information to users once they have signed up and confirmed their email address, is there a default/native way to do this in django-allauth? At the moment the system uses email_confirmation_message.txt to configure the email for users to confirm their email address, but we couldn't find something similar once the account is confirmed.
Yes, there is a way: django-allauth emits signals in various phases of the user signup process, including a signal when the user confirms their email:
allauth.account.signals.email_confirmed(request, email_address)
Adding a listener for that signal should solve your problem.

Python - AWS Cognito require verification email confirmation on user email change

I've been looking through the AWS Cognito docs for Python. When a user wants to change their email on my app, a verification email should be sent to that new email address to ensure they own it and once that's clicked it should change the email attribute. I can change the user email easily with update_user_attributes(), but the issue is that I don't see a way to require the user to be verified via an email before that change is initiated. It's also harder to deal with, because Cognito is disentangled from the server. Any suggestions how to implement this feature with Cognito? More than likely I think I'll have to implement the verification email part myself and call Cognito server when the user is verified.

Python Social Auth User without email

There is one problem. I need users` emails to register a new one in my application. In other words, email is required for users. But there are Facebook accounts that do not have an email attached. So, in a result, we get an error.
I see one solution: when we recognized that Facebook returned us data without Facebook, show a form where a user should enter his email, he wants to use in the application. And then we can continue register process. But how to realize this? Actually, I have no idea.
What about you?
Thanks
Python social auth partial pipelines is the feature for that, their purpose is to interact with the user to fetch extra data needed for the authentication, for instance requiring emails, confirming the email address, etc.
Check the example application at https://github.com/python-social-auth/social-examples/blob/master/example-django/example/settings.py#L216, it implements a partial pipeline that requests user email if it's missing from the authentication data.

Best way to retrieve email from a open id that does not provide it using python social auth

I've successfully implemented python social auth in my django application however I noticed that twitter does not provide an email address for me to save. is there a way of extending the social auth pipeline so I can ask for a new users email address if one is not provided?
The way to do it is by extending the default pipeline with a function that checks if an email was provided and ask for one in not. Check the example application at https://github.com/omab/python-social-auth/blob/master/examples/django_example, it does that with this pipeline https://github.com/omab/python-social-auth/blob/master/examples/django_example/example/app/pipeline.py.
Basically the flow is:
User signup with twitter
That pipeline checks if the user is new and if an email was returned by the auth provider
If no email, then redirect the user to a form, otherwise continue (the form POSTs to /complete/twitter, that way the auth process will continue where it stopped)
The pipeline function is ran again, but an email is detected in the request POST data
The pipeline stores the email in the details which is used to create the user later

Get facebook emails using django

I'm using django-socialregistration and facebook python sdk.
This is the code to get friends:
friends = request.facebook.graph.get_connections('me', 'friends')
I can get their name and id but I can't get their email address (not their #facebook.com email).
This is another attempt which also can't get their email.
for friend in friends['data']:
request.facebook.graph.get_object(friend['id'])
How can I get the facebook friends email?
It is possible to get the email of a user connected to your app using Graph. However, when connecting or signing in using Facebook users must explicitly give you permission to use their email address. Since none of the friends gave you permission, their e-mail addresses are off limits. What this means is you can encourage the user to have their friends join as well, and make sure that when they sign up you include a request for their e-mail address.
I think you are not getting the email from friends because this is not even possible to get from Facebook`s Graph API.
Check this out:
Facebook Graph API, how to get users email?

Categories