T-Mobile WiFi Hotspot login script

T-Mobile’s WiFi Hotspot service, thankfully, forgoes a proprietary authentication mechanism for a solution that while cross platform (i.e. it works with Linux), can be extremely annoying. On opening a web browser and attempting to go to any website, you’re required to login on an SSL-protected website with your account username and password before you can use the connection. If your web browser automatically tries to open many pages on startup, such as when you’re using the Session Saving extension for Firefox, you get T-Mobile’s Hotspot login page in every tab—extremely annoying!

I’ve written a small Python script that can login programatically without use of a web browser.

With no dependencies other than urllib, part of the Python Standard Library, the code is simple:

#!/usr/bin/env python

import urllib

params = { 
    'username': 'yourusername',  # Replace yourusername with your username
    'password': 'yourpassword',  # Replace yourpassword with your password
    'postURL': 'https://service2.hotspot.t-mobile.com/user/home',
    'Login': '',

params = urllib.urlencode(params)

f = urllib.urlopen("https://service2.hotspot.t-mobile.com:443/pages/checkInput.jsp", params)

Save the above code as something.py, set executable permissions (if required on your OS), and enter your username and password in their respective fields.

With a way to programmatically login, I can use Debian’s whereami package so automatically log me into a T-Mobile Hotspot, by simply going to one of their locations and turning on my laptop—no fiddling with anything.

Originally, I wanted to write this using the PyCurl bindings, just as an excercise so I could learn the API. Looking over the Curl API, however, convinced me that this was complete overkill. I’ll learn PyCurl when I’ve an application that requires a little bit more complication.

The request is simple enough that one should be able to login with just a crafted wget command; for some reason though, I was unable to get anything but an “Error 500 Internal Server Error” out of T-Mobile’s site when using wget.


Comments powered by Disqus