I'm making a KivyMD App and I want to send email verification code when an user is registered to the application. I'm using a firestore database with python for this project. But I don't have an idea to do that. The registration process is
User sign up to the application with his email address.
an email contains a code (with random numbers - OTP Code) should be send to the user's email.
After user enters the correct verification code he should be registered in the application.
Can this be done with the way I expected? Or are there other better ways? Please help me Friends. Thank you in advance...
Have you found the Firebase Python documentation? https://firebase.google.com/docs/reference/admin/python/firebase_admin.auth#generate_email_verification_link
It has explanations for the necessary functions to generate email verification links.
firebase_admin.auth.generate_email_verification_link(email, action_code_settings=None, app=None)
In order to send verification link on email you have to setup smpt server
import firebase_admin
from firebase_admin import credentials
from firebase_admin import auth
import smtplib
s = smtplib.SMTP('protonmail.com', 1025)
s.starttls()
s.login("your email", "pass0")
cred = credentials.Certificate('you_Secret.json')
firebase_admin.initialize_app(cred)
# creating the user
email = input('Please enter your email address : ')
password = input("Please enter your password : ")
user = auth.create_user(email=email, password=password )
link = auth.generate_email_verification_link(email, action_code_settings=None)
message = link
print(link)
s.sendmail("sender email", "reciever email", message)
# terminating the session
s.quit()
OUTPUT
link:https://hospitile.firebaseapp.com/__/auth/action?mode=verifyEmail&oobCode=_yM6YyEBt7e5Fyokjpbt4EUMw4eZzAe41n-t2oS-tNYAAAF9eZ-hnQ&apiKey=AIzaSyBJld5O_s09YVHoQ0ci7g3N3S-0DYjuH0U&lang=en
And when you click on that link you will be prompted to new tab below
Related
I'm trying to check if a user can log in to a specific sharepoint site using their user credentials.
from office365.runtime.auth.authentication_context import AuthenticationContext
ctx_auth = AuthenticationContext(url)
try:
if ctx_auth.acquire_token_for_user("email", "password"):
print("Get access")
except:
print("access denied")
But this sharepoint site uses multiple factor authentication and I get the following error:
An error occurred while retrieving token from XML response: AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access ''
This question had a similar problem and the answer was to use a generated "client_id" and 'client_secret'
In addition to this, I also have to check the user credentials to grant a user access.
Is this possible?
As far as I know, if MFA is enabled for SharePoint, it's not possible to use name and password to grant user access.
Everytime, I am trying to login into my Gmail account using python script it always shows authentication failed . I have used the right username and password, My internet connection is stable and I have turned on the 'less secure app access' from gmail setting.
from imap_tools import MailBox
with MailBox('imap.mail.com').login('sample#gmail.com', 'exm123') as mailbox:
subjects = [msg.subject for msg in mailbox.fetch()]
mailbox = MailBox('imap.gmail.com')
mailbox.login('sample#gmail.com', 'exm123', initial_folder='INBOX') # or mailbox.folder.set instead 3d arg
subjects = [msg.subject for msg in mailbox.fetch(AND(all=True))]
mailbox.logout()
I'm trying to fetch inboxs/emails from my gmail by using python. However, the code im using doesnt reem to run? I'm following a tutorial and my output is different. I'm new to python.
import email
import imaplib
username = '****#gmail.com'
password = '****'
mail = imaplib.IMAP4_SSL("imap.gmail.com")
mail.login(username, password)
mail.select("inbox")
When I run it via visual studio, I get this error.
I turned on let secure apps access feature on my google account, turned on imap on my gmail settings. What am I doing wrong? I'm trying to fetch emails from gmail and view inboxes and such.
Any help?
Looks like the code is fine.
test
Can you try this? I added a print statement and trying to access the content.
import imaplib
username = '****#gmail.com'
password = '****'
mail = imaplib.IMAP4_SSL(IMAP)
mail.login(USERNAME, PASSWORD)
for i in mail.list()[1]:
l = i.decode().split(' "/" ')
print(l[0] + " = " + l[1]) #should print the mail content that you can use as needed
I am trying to write a script on Python that fetches my friend list from facebook. To fetch data, I need to get the access token. I am using requests_oauthlib package to achieve the same. Since I am not writing a web application, I have not used local webserver(no redirect url). I choose to use Resource owner password credentials grant type. I am getting error.
This is my code:
from requests_oauthlib import OAuth2Session
from oauthlib.oauth2 import LegacyApplicationClient
FACEBOOK_APP_ID = '**********'
FACEBOOK_APP_SECRET = '*********'
username = 'Aman Mittal'
password = '****'
token_url = "https://graph.facebook.com/oauth/access_token"
oauth = OAuth2Session(client=LegacyApplicationClient(client_id=FACEBOOK_APP_ID))
oauth_access_token = oauth.fetch_token(token_url, client_secret=FACEBOOK_APP_SECRET,username=username, password=password, client_id=FACEBOOK_APP_ID)
When I run the script, it shows error - 'Missing access token parameter'
I went through traceback and realized that access token received is this:
{"error":{"message":"Missing redirect_uri parameter.","type":"OAuthException","code":191,"fbtrace_id":"CUSmQKT8YGb"}}
First of all, I don't understand while using Legacy Application client(Resource Owner password credentials grant type ), why do I need redirect uri?
If I do choose to start a webserver alongside using web.py or something else. How do I register it on Facebook? or Do I even need to?
PS. I am new to both Python and posting on Stack Overflow. Please try to explain with details and forgive me if I have committed any stupid mistake.
Facebook does not support the OAuth 2.0 Resource Owner Password Credentials grant type.
I initially tried using the smptlib library but in order to send an e-mail I need to use SSL which costs me with Google App Engine. Other than that, smtplib was a perfect solution.
I found a link here which explains how to send an email using the GAE API.
However, I can't seem to figure out how one would log in to a gmail account say, in order to send the email.
The purpose of this is to send a verification email to addresses of those who are registering. But in the link it shows how to get the current_user and send the email using their credentials. How would I explicitly enter an email, password, and smtp server like I would do with smtplib in order to send the email from my desired address.
Thanks for any answers!
You can't send from an arbitrary email address. As the overview docs state, you can only send from:
The Gmail or Google Apps Account of the user who is currently signed in
Any email address of the form anything#appname.appspotmail.com or anything#appalias.appspotmail.com
Any email address listed in Email API Authorized Senders found in the App Engine Settings page of the Developers Console
If you are the owner of the email account you want to send from, and it is a GMail account, you can add it to the Email API Authorized Senders list from the App Engine console.
Once that's done, you can just use it as the sender address - you don't need to log into anything.