Monday, December 19, 2011

I want to connect emesene to msn through the new xmpp service howto

Actually, things are quite simple! [1] And no, before you continue
reading, this is NOT working as you could expect.
After reading this [2] i've seen you don't need to provide a secret
key in order to authenticate with the live xmpp server so i registered
the "emesene" app in windows live and set the "mobile" flag.

If you'd like to try playing a bit with it just grab this emesene
branch [3] and follow the instructions below:

You can now use the client_id i obtained
"client_id": "000000004C070D1E",
in order to do an oauth2-auth with your favourite browser (remember:
this is a quick and dirty howto, it's not meant for everyday msn
users!).
Just navigate to:
https://oauth.live.com/authorize?client_id=000000004C070D1E&redirect_uri=https://oauth.live.com/desktop&response_type=token&scope=wl.messenger
wl.offline_access
(yes, space included..not sure if wl.basic or whatever else is needed
too) and after being prompted for your user/pass you'll see the url
just changed to something like
https://oauth.live.com/desktop#access_token=YOUR_ACCESS_TOKEN&token_type=bearer&expires_in=3600&scope=wl.offline_access%20wl.messenger


Note down the access token thing and run the emesene branch i told you
about before

Now, providing you already have some sort of live id (note: i tried
this only with an @hotmail.com address), say YOUR_USER at whatever.com,
you select msn-xmpp from the service's dropdown menu and put
YOUR_USER at messenger.live.com as user, and the previously-noted-down
long and ugly access_token as password.
Click connect and after a few seconds you shall see some of your
contacts (and some nice exception infinite loop in console, yay)

I included the latest xmpppy available in that branch so it can be
easily tested..but i added a really tiny modification to sasl auth in
order to support msnxmpp's
elif "PLAIN" in mecs:
sasl_data='%s\x00%s\x00%s'%(self.username+'@'+self._owner.Server,self.username,self.password)
node=Node('auth',attrs={'xmlns':NS_SASL,'mechanism':'PLAIN'},payload=[base64.encodestring(sasl_data).replace('\r','').replace('\n','')])
else:
becomes
elif "PLAIN" in mecs:
sasl_data='%s\x00%s\x00%s'%(self.username+'@'+self._owner.Server,self.username,self.password)
node=Node('auth',attrs={'xmlns':NS_SASL,'mechanism':'PLAIN'},payload=[base64.encodestring(sasl_data).replace('\r','').replace('\n','')])
elif "X-MESSENGER-OAUTH2" in mecs:
sasl_data='%s'%(self.password)
node=Node('auth',attrs={'xmlns':NS_SASL,'mechanism':'X-MESSENGER-OAUTH2'},payload=sasl_data)
else:

I don't plan to work on it, i just wanted to see if there was
something that could be done with minimal effort so feel free to try,
improve and why not completely integrate (e.g. in-emesene oauth2 with
some sort of webview, fix xmpppy with msnxmppy etc.) it in upstream
emesene!

I forgot to add: if you'd like to start some xmpp hacking with python,
i asked around and people have been recommending SleekXMPP

website: https://github.com/fritzy/SleekXMPP

real world example usage: http://poezio.eu/en/index.php

if someone is interested you could write an extension just like
"emesene/e3/jabber" and maybe supersede xmpp usage


tl;dr: msn supporting xmpp is really nice, but having it 100% working
is not so easy

Have fun,
Riccardo (c10ud)

___

[1] - which doesn't mean you'll have it working 100%
[2] - http://blogs.gnome.org/xclaesse/2011/12/19/updates-on-xmpp-support-in-msn/
[3] - https://github.com/c10ud/emesene/tree/msn-xmpp

5 comments:

Anonymous said...

When I load that url, it says invalid scope.

Alexandre said...

Mine is not working 100% since forever, I'm sure give it a try (:

Alexandre said...

it's faster than the original thing to login, and I'm using it for like, almost and hour, has some bugs on it, but, in my opinion, it's better than the original/old one

if you decide to keep going with it, count on me as bugfinder (IDK how to code, soo.. haha

Ivo Anjo said...

You might be interested in how gajim solved this in a simple way also:
https://trac.gajim.org/ticket/6978

Gajim hosts a small server-side script (which everyone can host, source is attached to the ticket), that then presents the user with a simple page asking him/her to "copy/paste" the key.

Angelina said...

Gajim hosts a small server-side script (which everyone can host, source is attached to the ticket), that then presents the user with a simple page asking him/her to "copy/paste" the key.

Facebook App Developer