开发者

XMPP implementation in silverlight authentication returns failure

开发者 https://www.devze.com 2023-03-14 04:01 出处:网络
I am trying to implement Xmpp protocol in silverlight and trying to connect to Facebook, here I am getting everything correct until <challenge .. > obtained from server.

I am trying to implement Xmpp protocol in silverlight and trying to connect to Facebook, here I am getting everything correct until <challenge .. > obtained from server. I am using X Facebook platform authentication. I have done this with following code:

byte[] ch = Convert.FromBase64String(message.challenge);
string challenge = System.Text.Encoding.UTF8.GetString(ch, 0, ch.Length);
string response = "";
long callId = DateTime.UtcNow.Ticks;
MD5 md = new MD5();

String signature1 = "api_key=203366556348506"
+ "call_id=" + callId
+ "method=auth.xmpp_login"
+ param[2]
+ "session_key=" + messageClient.SessionKey
+ "v=1.0"
+ messageClient.AppSecret;
md.Value = signature1;

response = "method=auth.xmpp_login&api_key=203366556348506&session_key=bc6d6e00462cc2bb73a824bd.4-100001565408667&call_id=" + callId + "&sig=c47d741cb8f18c4e78b990f48e2f63aa&v=1.0&" + param[2];


message.Request = "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(开发者_开发知识库response)) + "</response>";
this.messageClient.SendMessageAsync(message);

But I am getting following message from server:

<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>

Please let me know where I am going wrong.


Try following code:

String signature1 = "api_key=" + messageClient.ApiKey
    + "call_id=" + callId
    + "method=auth.xmpp_login"
    + param[2]
    + "session_key=" + messageClient.SessionKey
    + "v=1.0"
    + messageClient.AppSecret;

md.Value = signature1;

response = "method=auth.xmpp_login&api_key=" + messageClient.ApiKey + "&session_key=" + messageClient.SessionKey + "&call_id=" + callId + "&sig=" + md.FingerPrint.ToLower() + "&v=1.0&" + param[2];

I have changed response string to the one above.

This has returned success for me. Hope this will help you.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号