首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如果使用X-FACEBOOK-PLATFORM机制,则XMPP身份验证失败

如果使用X-FACEBOOK-PLATFORM机制,则XMPP身份验证失败
EN

Stack Overflow用户
提问于 2012-03-03 17:46:24
回答 2查看 1.7K关注 0票数 1

我正在尝试制作一个facebook聊天应用程序。

我想通过X-FACEBOOK-PLATFORM机制登录XMPP服务器。

但当我完成身份验证步骤时,我失败了。

如果我使用DIGEST-MD5机制,我可以成功登录到XMPP服务器(在本例中,我使用JID作为username@chat.facebook.com,使用Password作为我的facebook密码)。

对于X-FACEBOOK-PLATFORM机制,我使用JID作为uid@chat.facebook.com,获取我的访问令牌、uid、过期日期等都没有问题。

当然,我得到了facebook的“xmpp_login”许可。

出什么问题了?

以下是解码后的日志消息。

代码语言:javascript
复制
AppDelegate: xmppStream:socketDidConnect:
SEND: <?xml version='1.0'?>
SEND: <stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' to='chat.facebook.com'>
RECV: <stream:stream xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" id="FAA1CDE5" from="chat.facebook.com" version="1.0" stream1: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: <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='X-FACEBOOK-PLATFORM'/>
XMPPCapabilities: My capabilities:
<query xmlns="http://jabber.org/protocol/disco#info">
  <feature var="http://jabber.org/protocol/disco#info"/>
  <feature var="http://jabber.org/protocol/caps"/>
</query>
RECV: <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
      version=1&method=auth.xmpp_login&nonce=0E51AA2E42C4AF8FCE9D996F347C7019</challenge>
SEND: <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
    method=auth.xmpp_login&nonce=0E51AA2E42C4AF8FCE9D996F347C7019&access_token=BAAEctIrR99oBAM9ZBymJSDmVZAYb82RX634ANVZCQ9VJeoD9ZCTqSGVyuxSQfbm9s92VGtwcewVJlP7C8CnIglkqZBCvq6ZBxxWhJoDmK0rPJGdM5i7KRu18bZAJoyKEI0ZD
    &api_key=313036725417946
    &call_id=150701328
    &v=1.0</response>
RECV: <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>
AppDelegate: xmppStream:didNotAuthenticate:
AppDelegate: xmppStreamDidDisconnect:withError:
EN

回答 2

Stack Overflow用户

发布于 2013-08-11 23:12:53

我也遇到了类似的问题,并通过在身份验证之前保护xmppstream解决了这个问题。

代码语言:javascript
复制
-(void)xmppStreamDidConnect:(XMPPStream *)sender{

DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);

isXmppConnected = YES;

if (![xmppStream isSecure])
{
    NSError *error = nil;
    BOOL result = [xmppStream secureConnection:&error];

    if (result == NO)
    {
        DDLogError(@"%@: Error in xmpp STARTTLS: %@", THIS_FILE, error);
        NSLog(@"XMPP STARTTLS failed");
    }
}
else
{
    NSError *error = nil;
    BOOL result = [xmppStream authenticateWithFacebookAccessToken:[NSString stringWithFormat:@"%@",FBSession.activeSession.accessTokenData] error:&error];

    if (result == NO)
    {
        DDLogError(@"%@: Error in xmpp auth: %@", THIS_FILE, error);
        NSLog(@"XMPP authentication failed");
    }
}
}
票数 2
EN

Stack Overflow用户

发布于 2012-06-05 14:44:45

试着用“-uid@chat.facebook.com”代替“uid@chat.facebook.com”。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9545074

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档