-
Notifications
You must be signed in to change notification settings - Fork 4
Webclient connections
Outlook.com contains a webclient for MSNP. This uses a long polling sort of gateway server.
The webclient uses cookies for authentication; these are granted by the Microsoft Account login form, both regular and OAuth. Exactly which ones are needed is unclear.
The cookies aren't sufficient for logging in: a uic value is required as well. This can be obtained by the following:
- POST the empty string to
https://go.trouter.io/v2/a. Let the response body bera. - Form a JSON object:
{"trouterurl": ra.url, "connectionid": ra.connId} - POST that object to
https://skypewebexperience.live.com/v1/user/Initialization, with the Content-Type set correctly and being sure to include the cookies. - The response you get from that contains the
uicas the value ofMappingContainer.
This seems to be a variation on long polling: ie, POST things you want to send, and keep a connection open for the server to send you things.
To start a session, POST your initial MSNP messages to https://geo.gateway.messenger.live.com/gateway/gateway.dll?Version=1&Protocol=mtp&Action=open&Server=NS&IP=none. There are two additional headers to be aware of that the webclient sends:
X-MSN-Auth: Use-Cookie
X-Requested-Session-Content-Type: text/html
The response body will be whatever MSNP messages the server deems necessary to send you, and will have some interesting headers:
X-MSN-Host: <hostname>.gateway.messenger.live.com
X-MSN-Messenger: SessionID=<sid>; GW-IP=<ip>
X-MSN-SessionTimeout: 120
X-MSN-SkypeId: <username>
X-MSNSERVER: <hostname>
After this, whenever you want to send something, POST it to https://<X-MSN-Host>/gateway/gateway.dll?SessionID=<sid>. In order be able to receive something, POST the empty string to the same URL, but with the additional parameters Action=poll&Lifespan=60, and hold the connection open until the OS gets annoyed with you or you receive something. Then do it again.
I currently don't know how you tear down the connection.