简体   繁体   中英

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.

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.

In my app I am using the latest Facebook SDK and for getting the xmpp_login permission I'm doing the following:

[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 .

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).

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.

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.

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.

A quick workaround is to force newer SDKs to use v1.0 of the API.

[FBSettings enablePlatformCompatibility:YES];

API v1.0 will be available until April 15th of 2015 and facebook states the following:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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