fritzy / SleekXMPP

Python 2.6+/3.1+ XMPP Library
http://groups.google.com/group/sleekxmpp-discussion
Other
1.1k stars 299 forks source link

Auth Mechanism for MSN Messenger #177

Closed projml closed 12 years ago

projml commented 12 years ago

Hi, i'm using SleekXMPP version 1.1.7.

How do I set an Auth Mechanism? I've tried to connect to MSN Messenger XMPP Server, but didn't work (i'm kinda newbie with XMPP).

After reading this article => http://msdn.microsoft.com/en-us/library/live/hh826554.aspx I found out that I have to implement an Auth method named "X-MESSENGER-OAUTH2" and SASL.

Could someone give a sample code to do this? Also, someone could write a simple code how to connect to Messenger Live XMPP.

Thank you guys and sorry about my poor english.

legastero commented 12 years ago

First, you need to get an access token from MSN. Follow their documentation on what HTTP requests you need to make to do that. You will probably need to register an application first to do that. Getting the token is beyond the scope of SleekXMPP, so we don't do that automatically for you (it essentially requires a browser to complete).

Then it's just a matter of setting:

self.credentials['access_token'] = 'the_access_token_you_got'

Sleek already handles selecting the auth mechanism and has support for X-MESSENGER-OAUTH2. If you wish to ensure that only X-MESSENGER-OAUTH2 is used, you can do it by passing a sasl_mech parameter to the ClientXMPP constructor:

xmpp = ClientXMPP(jid, password, sasl_mech='X-MESSENGER-OAUTH2')

Do note that recently the MSN XMPP service started occasionally using a see-other-host redirect during stream establishment that Sleek does not support yet.

EDIT: corrected the credentials setting name to 'access_token'

projml commented 12 years ago

Legastero, thank you for the quick response. I'll try it to see what happens.

legastero commented 12 years ago

Sorry, I made an error above. You should set:

self.credentials['access_token'] = 'the_access_token_you_got'
legastero commented 12 years ago

Support for the see-other-host stream error has been added in the develop and master branches (it is an automatic reconnect, no special configuration is needed).

With that, MSN login is now fully supported again.

projml commented 12 years ago

Anyway, I could not make my code work. Also, I have not found any examples of code to connect to the MSN Messenger and my knowledge of Python is limited.

Thanks for the support, Legastero.