-
Notifications
You must be signed in to change notification settings - Fork 5
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 are sufficient for logging in. However, some versions of the webclient use a uic
value as 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
uic
as the value ofMappingContainer
.
The uic
value is used in the ATH CON\USER
message:
ATH 2 CON\USER 312
<user><uic>AAAAABnpOEW...vLV7w==</uic><web-compact-ticket /></user>
This is essentially the same method used by MSNP8-era clients: http://www.hypothetic.org/docs/msn/general/http_connections.php
The main difference is that HTTPS is enforced now, and the Lifespan
parameter allows for long-polling.
It's just that: 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
X-Requested-Session-Content-Type
is optional, probably just there to fix web browser compatibility issues. If not specified, the response content type is application/x-msn-messenger
.
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.
All requests must include the cookies you got when authenticating
I currently don't know how you tear down the connection.