firebase-admin python sending password reset email - python

In Python I am trying to do 'send a password reset email', javascript reference (https://firebase.google.com/docs/reference/js/firebase.auth.Auth#sendPasswordResetEmail). So far (and only recently) it looks like 'generate password reset link' was added (https://github.com/firebase/firebase-admin-python/releases). Does anyone know the next step in getting the email send? Do we send the email ourselves? If so, any suggestions? Is there a way to send the email in python directly?
Thanks for all your help in advance!

Might be late but for others to see:
email = 'user#example.com'
link = auth.generate_password_reset_link(email, action_code_settings)
# Construct password reset email from a template embedding the link, and send
# using a custom SMTP server.
send_custom_email(email, link)
More in here: https://firebase.google.com/docs/auth/admin/email-action-links#python_1

Thank you (bojeil-google) on Github for providing the answer. Apparently, the way to do this is to make a POST request per https://firebase.google.com/docs/reference/rest/auth/#section-send-password-reset-email . There is no direct call to do this in the python SDK. Thanks again!

Firebase-admin-sdk (python) is lack of methods to deal with user authentication. You can use Pyrebase. It's a wrapper for the firebase API.

Related

Any other ways to take info from Instagram API without logging in?

Problem: is here any ways to keep my login and password away from the code of a program (the program parse Instagram post info) that will be used by users? The code below takes info of the post, BUT if i make many requests to Instagram, it doesn't work. So i need to login in anyway instagram_web_api.login(LOGIN, PASSWORD), but my program will be used by another users.
Question: If my program will be used by another users, how can i hide my login and password from the code? I mean the program will be Desktop GUI, using code below partly, so users wouldn't see the code, BUT if they somehow look in the code, i want my login and password be hidden. Any ways, please?
Code:
...
def _parse_instagram_post(self):
instagram_web_api = Client()
instagram_web_api.login(LOGIN, PASSWORD)
media_pk = instagram_web_api.media_pk_from_url(POST_URL)
post_info = instagram_web_api.media_info(media_pk)
...
you can use Telegram Bot API
Why ?
Customers cannot access the source code.
More useful and easy
But if you don't prefer this way, you can
Obfuscate
Encrypt
Compile
your code.
I can suggest a few tools for these operations:
https://www.pyinstaller.org/
https://github.com/astrand/pyobfuscate
https://github.com/PyObfx/PyObfx
https://github.com/pycrypt123/pycryptor

API General Understanding in regards to Python Gmail-api

I just got started programming a year ago (on and off) and I am trying to save an attachment to a folder offline from my personal GMAIL account.
I was advised to use :
https://developers.google.com/gmail/api/quickstart/python
I set up the
I authenticated the my account and now am trying to get comfortable with this tool.
There are some initial questions that I have
What is User ID ?
is this my email ( tttt#xxxx.xxxx)
or someone else's email (ppppp#yyyy.yyy)
How do I get a email ID's ?
These questions stem from ...
GET https://www.googleapis.com/gmail/v1/users/userId/messages/messageId/attachments/id
from the page :
https://developers.google.com/gmail/api/v1/reference/users/messages/attachments/get
Again I am just learning from a beginner place..
Thanks
Just use "me" as the userId as it says in the doc.
To get a messageId first you have to search (list) messages, using something like:
resp = gmail.users().messages().list(userId="me", q="has:attachment subject:'foo bar' before:"2014-01-05").execute()
you can then iterate through the 'messages' in that resp and
gmail.users().messages().get(userId="me", id=message['id']).execute()
The Gmail API guides are quite helpful, take a look at them, for example:
https://developers.google.com/gmail/api/guides/filtering

Attachments getting attached twice using smptplib in python

I am trying to implement a functionality in python where I want to send a
file as an attachment to an email alert
Everything works fine. i am getting the email alert with required subject but the only problem is that I get the same attachment twice in my email alert.
fileMsg = email.mime.base.MIMEBase('application','octet-stream')
fileMsg.set_payload(file('/home/bsingh/python_files/file_dict.txt').read())
#email.encoders.encode_base64(fileMsg)
fileMsg.add_header('Content-Disposition','attachment;filename=LogFile.txt')
emailMsg.attach(fileMsg)
# send email
server = smtplib.SMTP(smtp_server)
server.starttls()
server.login(username, password)
server.sendmail(from_add, to_addr,emailMsg.as_string())
server.quit()
I have been having problems with this myself. I had 'alternative' as my message's MIMEMultipart type. When I changed to the default, 'mixed', the duplicate disappeared.
So if you created emailMsg using MIMEMultipart('alternative'), you may have the same problem.
I believe 'alternative' is for offering both a text and html version of the message body, so I think you need to offer both in addition to your attachment if you use it.
I hope that helps.
I have not found a good explanation of this anywhere yet; email can get pretty complicated.
The whole purpose of yagmail (I'm the developer) is to make it really easy to send emails, especially with HTML or attachment needs.
Please try the following code:
import yagmail
yag = yagmail.SMTP(from_add, password)
contents = ['See my attachment below', '/home/bsingh/python_files/file_dict.txt']
yag.send(contents = contents)
Notice the magic here: contents is a list, where an item equal to a file path will automatically be loaded, mimetype guessed, and attached.
There's a lot more magic involved, such as easy to embed images, passwordless scripts, usernameless scripts, easy aliases, smart defaults (notice I omitted the to and subject arguments?) and much more. I advise/encourage you to read its github page :-). Feel free to raise issues or add feature requests!
You can get yagmail by using pip to install it:
pip install yagmail # Python 2
pip3 install yagmail # Python 3
There was an issue with the version..Has been resolved

Yowsup Authentication don't work

I'm trying to make some test with this nice library.
I have made successfully tests with yowsup-cli but now I'd like to create a small python script to manage in a smart ways events (with listener/callback).
I'm trying the code explained here https://github.com/tgalal/yowsup/wiki/Yowsup-Library-Documentation:
def onAuthSuccess(username):
print "Logged in with %s" % s
# make a call to method ready to be able to receive messages
methodsInterface.call("ready")
y = YowsupConnectionManager()
signalsInterface = y.getSignalsInterface()
methodsInterface = y.getMethodsInterface()
signalsInterface.registerListener("auth_success", onAuthSuccess)
methodsInterface.call("auth_login", ("username", "password"))
Is clear that username should be nationNumber + phoneNumber without other symbols. But is not clear to me where the password should be found.
With cli the authentication mechanism is different and it need a registration.
Can you help me please? Thanks
Just incase someone has the same problem that authentication isn't working though you're passing the right username and password as argument, You have to base 64 encode the password like is done in the Command Line client.
You have to get the password by registering using Yowsup or WART OR from your phone ( https://github.com/tgalal/yowsup/issues/234 ? )
import base 64
password= 'randomletters+somenumbers=' #Get this by registering
password = base64.b64decode(bytes(rawPass.encode('utf-8')))
This is not obvious and i forget often and might be what's going wrong.
you probably want to write
import base64
Nevertheless, this is still not working for me, though sending messages with yowsup-cli works fine.
There still seems to be a difference in authentication I have not understood.

send sms from gmail using python script

I am trying to work for sending sms from gmail using python.
I have tried many solutions but it didnt worked.
I tried to use libgmail but seems to be deprecated. Even I am not able to find how to send sms from gmail to jawwal where as actually gmail sends free sms to jawwal.
My code is:
import libgmail
from TextMessaging import *
sender = Sender(<username>, <password>)
txtM = TextMessage(subject, body)
receiver = Receiver("<phone no>", "Jawwal")
sender.sendMessage(receiver, txtM)
in this, on sender it gives error as expected string or buffer
and for reciever, i dont know whats carrier for jawwal like
CARRIERS = {"Alltel":"alltelmessage.com",
"ATT":"mobile.mycingular.com",
"Rogers":"pcs.rogers.com",
"Sprint":"messaging.sprintpcs.com",
"tMobile":"t-mobile.net",
"Telus":"msg.telus.com",
"Verizon":"vtext.com"}
Kindly give me on any information how to send sms to gmail using python script.
Thanks
Perhaps you would want to use one of these services:
[https://www.twilio.com/sms][1]
[http://www.clockworksms.com/][2]
They provide REST API options.
I know this is an old question, but just posting for someone searching for an answer.
"As of April 1, 2014, sending SMS messages to phone contacts through Google Chat in Gmail was
discontinued for all supported mobile operators."
https://support.google.com/chat/answer/112176?hl=en
I think the carrier's email address for your phone is as such:
jawwal.com.country_code
Replace country_code with the appropriate URL extension (.sa, .lb, etc.).

Categories

Resources