Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
OnAuthError
Avatar
Chivenele #1
Member since May 2012 · 3 posts
Group memberships: Members
Show profile · Link to this post
Subject: X-FACEBOOK-PLATFORM authentication
Hello,

I have a problem with X-FACEBOOK-PLATFORM authentication mechanism. I tried to find solution on forum, but I found nothing. Everything works fine with DIGEST-MD5.

Here is my code.

his.xmppClient = new XmppClient()
            {
                Password = this.account.Password,
                Username = this.account.Username,
                XmppDomain = this.account.Domain,
                Status = "Online",
                Show = Show.chat,
                Port = 5222,
                StartTls = true,
                Hostname = "chat.facebook.com",
            };

            // Event handlers for Matrix
            this.xmppClient.OnBeforeSasl += this.xmppClient_OnBeforeSasl;
            this.xmppClient.OnLogin += this.XmppClient_OnLogin;
            this.xmppClient.OnAuthError += this.XmppClient_OnAuthError;
            this.xmppClient.OnError += this.XmppClient_OnError;

            this.xmppClient.OnRosterStart += this.XmppClient_OnRosterStart;
            this.xmppClient.OnRosterItem += this.XmppClient_OnRosterItem;
            this.xmppClient.OnRosterEnd += this.XmppClient_OnRosterEnd;
            this.xmppClient.OnReceiveXml += this.XmppClient_OnReceiveXml;
            this.xmppClient.OnSendXml += this.XmppClient_OnSendXml;

            try
            {
                this.xmppClient.Open();
            }
            catch (Exception ex)
            {
                Console.WriteLine("During the open");
                Console.WriteLine(ex.Message);
            }

            Thread.Sleep(500*60);

            this.xmppClient.SendPresence(Show.chat, "Online");

            // Get Online users
            this.xmppClient.OnPresence += this.XmppClient_OnPresence;
            this.xmppClient.AutoRoster = true;


 public void xmppClient_OnBeforeSasl(object sender, Matrix.Xmpp.Sasl.SaslEventArgs e)
        {
            Console.WriteLine("OnBeforeSasl");
            e.Auto = false;
            e.SaslMechanism = Matrix.Xmpp.Sasl.SaslMechanism.X_FACEBOOK_PLATFORM;
   
            e.SaslProperties = new Matrix.Xmpp.Sasl.Processor.Facebook.FacebookProperties
                                   {
                                       ApiKey = AppId,
                                       ApiSecret = AppSecret,
                                       AccessToken = this.accessToken
                                   };
            Console.WriteLine(e.SaslProperties);
        }

And XML:

SEND: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="chat.facebook.com" version="1.0" >
RECV: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" id="46E9AD61" from="chat.facebook.com" version="1.0" xmlns="jabber:client" xml:lang="en" >
RECV: <stream:features xmlns:stream="http://etherx.jabber.org/streams">
  <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
  <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
    <mechanism>X-FACEBOOK-PLATFORM</mechanism>
    <mechanism>DIGEST-MD5</mechanism>
  </mechanisms>
</stream:features>
SEND: <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
RECV: <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
On TLS state = Matrix.EventArgs
SEND: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="chat.facebook.com" version="1.0" >
RECV: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" id="29C60E1A" from="chat.facebook.com" version="1.0" xmlns="jabber:client" lang="en" >
RECV: <stream:features xmlns:stream="http://etherx.jabber.org/streams">
  <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
    <mechanism>X-FACEBOOK-PLATFORM</mechanism>
    <mechanism>DIGEST-MD5</mechanism>
  </mechanisms>
</stream:features>
SEND: <auth mechanism="X-FACEBOOK-PLATFORM" xmlns="urn:ietf:params:xml:ns:xmpp-sasl" />
RECV: <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dmVyc2lvbj0xJm1ldGhvZD1hdXRoLnhtcHBfbG9naW4mbm9uY2U9RDJGRjU2MzZCNkQ3NjFEMjQyNDRFNDMwQzI3RENDRjE=</challenge>
SEND: <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">bWV0aG9kPWF1dGgueG1wcF9sb2dpbiZhcGlfa2V5PTM2NjA2MTc3MDA5ODk1NSZhY2Nlc3NfdG
9rZW49QUFBRk03bVhGeVFzQkFHVWhPRnRKem96QTNJaFFMc2tBYlJDYUtRSVYxdGlDWkNtY2I5ZW9POFFaQXdFd21TY3ZtbmFWaFJtc0s3czlHbDh6NXpvRHpEeHh5RUFjckFMaTNFU3dTcXpRWkRaRCZ2PTEuMCZjYWxsX2lkPTQ4NTgwOTU5OSZub25jZT1EMkZGNTYzNkI2RDc2MUQyNDI0NEU0MzBDMjdEQ0NGMQ==</response>
RECV: <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
  <not-authorized />
</failure>
OnAuthError!
SEND: </stream:stream>
RECV: </stream:stream>


Thank you! Raman
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Have you studied this?
http://www.ag-software.net/matrix-xmpp-sdk/matrix-develope…

Do you request the xmpp_login permission?

Alex
Avatar
Chivenele #3
Member since May 2012 · 3 posts
Group memberships: Members
Show profile · Link to this post
Yes, I've studied this.
I registered my app on Facebook and in menu "Configure how Facebook refers users to your app" - "Extended permissions" specified xmpp_login, but nothing more.
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
AFAIK you have to request the permission when you retrieve you token in the web API/Url.

Alex
Avatar
Chivenele #5
Member since May 2012 · 3 posts
Group memberships: Members
Show profile · Link to this post
I made some manipulations with my app page on facebook, added permissions request to my url and now it's working!
Thank you, Alex!
Avatar
Alex #6
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
great to hear.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters: