简体   繁体   English

获取xmpp_login访问令牌在Facebook iOS SDK中不起作用

[英]Getting xmpp_login Access Token Not Working in Facebook iOS SDK


I'm trying to get a valid accessToken to send messages via XMPP from my iOS App. 我正在尝试获取有效的accessToken,以便通过我的iOS应用程序通过XMPP发送消息。

I'm using this library for that ( https://github.com/KanybekMomukeyev/FacebookChat ) and everything seems to work well, but it uses an old xmpp library and an old Facebook sdk. 我正在使用这个库( https://github.com/KanybekMomukeyev/FacebookChat ),一切似乎都运行良好,但它使用旧的xmpp库和旧的Facebook sdk。

In my app I am using the latest Facebook SDK and for getting the xmpp_login permission I'm doing the following: 在我的应用程序中,我使用最新的Facebook SDK并获取xmpp_login权限,我正在执行以下操作:

[FBSession openActiveSessionWithReadPermissions:@[@"xmpp_login"] allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
    ...
}];

I get no error but when I trie to use the resulting accessToken with the xmpp library I continue to get a No Authenticated error . 我没有得到任何错误,但当我试图使用xmpp库生成的accessToken时,我继续得到No Authenticated error

Digging around I end up inspecting the url that facebook uses for requesting the token in the new SDK (My app) and in the old SDK (Facebook Chat). 挖掘我最终检查facebook用于在新SDK(我的应用程序)和旧SDK(Facebook聊天)中请求令牌的URL。

Mine: 矿:

https://m.facebook.com/v2.0/dialog/oauth?sdk_version=3.15.0&response_type=token&return_scopes=true&legacy_override=v2.0&e2e={"init":1404191289978}&scope=xmpp_login&client_id=274849106003593&state={"is_open_session":true,"is_active_session":true,"com.facebook.sdk_client_state":true,"3_method":"browser_auth","0_auth_logger_id":"72796574-5B5C-4EF3-9B0B-F9AC376E2DC4"}&redirect_uri=fb274849106003593://authorize&sdk=ios&display=touch

Them: 他们:

https://m.facebook.com/dialog/oauth?type=user_agent&display=touch&redirect_uri=fb274849106003593://authorize&sdk=ios&scope=xmpp_login&client_id=274849106003593

I'm not really sure why one works and the other doesn't, I get accessTokens in both cases but if I request with the first URL XMPP doesn't authenticate. 我不确定为什么一个工作而另一个不工作,我在两种情况下都获得accessTokens但是如果我使用第一个URL请求XMPP不进行身份验证。

Does anyone know why this happen or what else need to be included in the permissions? 有谁知道为什么会发生这种情况或者需要在权限中包含哪些内容?

PS: By the Way if you try the second(old way) URL any subsequent request will work until the token expires. PS:顺便说一句,如果您尝试第二个(旧方式)URL,任何后续请求都将有效,直到令牌过期。

According to Facebook ( https://developers.facebook.com/docs/apps/changelog ) their API v2.0 removes access to the xmpp_login permission and that is why it isn't working. 根据Facebook( https://developers.facebook.com/docs/apps/changelog ),他们的API v2.0删除了对xmpp_login权限的访问权限,这就是它无法正常工作的原因。

A quick workaround is to force newer SDKs to use v1.0 of the API. 一个快速的解决方法是强制较新的SDK使用API​​的v1.0。

[FBSettings enablePlatformCompatibility:YES];

API v1.0 will be available until April 15th of 2015 and facebook states the following: API v1.0将于2015年4月15日前发布,facebook将声明如下:

Apps that were inactive or have a creation date on or after April 30th, 2014 will not be able to make calls to v1.0 of the API. They must use v2.0.

So xmpp is not a viable solution anymore. 所以xmpp不再是一个可行的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM