I keep getting HTTPError: 403 Client Error: Forbidden for url: https://www.textnow.com/api/users/my_username/messages
I can't get a simple script to send a test message. I keep getting an error 403
The code looks like this:
from pythontextnow import Client
USERNAME = "myuser.name"
SID_COOKIE = see below
Client.set_client_config(username=USERNAME, sid_cookie=SID_COOKIE)
from pythontextnow import ConversationService
PHONE_NUMBER = "+14165551234"
conversation_service = ConversationService(conversation_phone_numbers=[PHONE_NUMBER])
conversation_service.send_message(message="Hello World!")
The error I get:
Traceback (most recent call last):
File "/home/liviu/textnow/victor/test.py", line 13, in
Clearly I am missing something in the authentication but I have no idea what. The cookie looks like this (I changed a few characters from the real one) connect.sid=s%3Ah1zL9MFKwr3YU2EhgRexzB8zW7EZnPYI.xeFi4FWhEgBLPWUcfhkOgG7v2wvDyCzYEU3%2FOoJLS5E Does it mean my SID_COOKIE = "s%3Ah1zL9MFKwr3YU2EhgRexzB8zW7EZnPYI.xeFi4FWhEgBLPWUcfhkOgG7v2wvDyCzYEU3%2FOoJLS5E" ? I tried also to replace %3A and %2F so the string becomes SID_COOKIE = "s:h1zL9MFKwr3YU2EhgRexzB8zW7EZnPYI.xeFi4FWhEgBLPWUcfhkOgG7v2wvDyCzYEU3/OoJLS5E" but neither one works. Also, my username has a period, does that character need to be escaped in some way ? Thanks for any feedback
it might be something with the user agent, sometimes it works, and sometimes i get this error
Thanks. What is the correct user agent and how can one specify it ?
Try again with version 1.1.0
pip install --upgrade pythontextnow
Thank you so much for the update. It does work now. There was another issue, which I just realized. TextNow kept telling me to disconnect the VPN when I was trying to use it from the browser. Obviously I had no VPN and couldn't figure out how to get rid of the error. When I released the IP address from my ISP and got a new IP, the error went away.
Having the same issue right now with the same identical code as above. My username and SID is correct as I'm able to use other methods such as get_messages() and print out messages, but when it comes to send_message(), I am getting the 403 Client Error.
I have also tried "pip install --upgrade pythontextnow"
Are you able to send messages from a browser from the same IP address ? One of my issues was that I was getting an error "turn off VPN" when sending from the browser, at the same IP address.
What do you mean by sending messages from the same IP address? I don't have VPN installed. I am not getting a "turn off VPN" error - how did that come about? Was it through the IDE?
I also tried to release my ip address via sudo ipconfig set en0 DHCP, my ip address became undetected and I just got back my same ip address as before
Edit: was able to get the vpn error popup by going on safari. i was initially on chrome
Then I am guessing your issue isn't the same as mine. I was working with 2 PCs. One was a Linux machine where I was trying to run the pythontextnow script and one was a Windows box where I logged in from a web browser to collect the cookie, etc. Both machines were running behind the same firewall/public IP, with no VPN (but somehow TextNow had my IP address flagged as being some VPN provider). The Windows one was giving me the VPN error while the Linux one was just throwing the 403 error. When I restarted the internet connection to get another IP address, both PCs started working.
I have same error. I have updated version to 1.1.0 with pip install --upgrade pythontextnow I have also updated the SID_COOKIE.
@joeyagreco Using pythontextnow 1.1.0 for a while, recently have not been able to connect and getting error:
"File "/opt/PythonTextNow/Keep_TextNow_Alive.py", line 27, in
@joeyagreco PS: changed to a new SID Cookie but get same connection error. Do not know if this would cause the error but the user agents seems to have changed. Where does this get specified?
I too am getting this error now on Debian 12+Python3.11.
Traceback (most recent call last):
File "/home/textnow/ptn.py", line 17, in
This was also on a fresh SID cookie. A different Python TextNow API project that had been working stopped working sometime between January 31st and February 7th of 2025. Is it possible that TextNow has changed their API? Many thanks to @joeyagreco for this project and any help on this would be appreciated.
Same. 403 error. I'm guessing textnow made some changes?
I am also getting 403 error, even with updated cookie. I was using this script with 2 accounts, to keep the numbers from expiring, and one account already got blocked. It feels that somehow TextNow are now able to detect when someone uses this script.
I am not actively maintaining this, as I currently have no incentive to do so and have other obligations.
As long as TextNow works in a browser, fixing issues like this should be relatively trivial.
Pull requests are welcome.
got 403 errors in the past few days, today it's magically working again.
Took a long look at resolving the 403 error, with no success. The conclusion I come to is that TextNow is now using Cloudflare which is blocking python requests. Beyond my ability on how to get around this... @joeyagreco
Took a long look at resolving the 403 error, with no success. The conclusion I come to is that TextNow is now using Cloudflare which is blocking python requests. Beyond my ability on how to get around this... @joeyagreco
@ClearlyDazed et al. Please refer to Issue 39 for a solution.