Can someone please try the code below (with own Facebook app id) to verify that it is not working?
If a user logs in without Facebook first and then links account with externalAccountLink it does not work. Actually the console.out output looks fine, there is a Facebook external account id, but when I look into the user data on server by using app management the entry is missing. When I try to search for Facebook friends I am getting an error that the account is not authorized for Facebook.
I am using SDK 3.5.1.
code
var Cloud = require('ti.cloud'); var facebook = require('facebook'); facebook.appid = 1455001824784603; facebook.permissions = ['read_stream','email','user_friends']; var onFacebookLogin=function(e) { facebook.removeEventListener('login', onFacebookLogin); Cloud.SocialIntegrations.externalAccountLink({ type: 'facebook', token: facebook.accessToken, }, function (e) { if (e.success) { var user = e.users[0]; console.log("accountlink successful. user data:"+JSON.stringify(user)); Cloud.SocialIntegrations.searchFacebookFriends(function (e){ if (e.success) { console.log("searchFacebookFriends successful"); } else { console.log("searchFacebookFriends not successful"); console.log('Error:\n' + ((e.error && e.message) || JSON.stringify(e))); } }); } }); }; var userData = { username: "test", password: "test", password_confirmation: "test" }; Cloud.Users.create(userData, function (e) { if (e.success) { console.log('registration successful'); var user = e.users[0]; facebook.addEventListener('login', onFacebookLogin); facebook.authorize(); } else { console.log('registration not successful'); } });console output
[INFO] : Application started [INFO] : Math Hero/1.0.27 (3.5.0.0014f83) [INFO] : Ti.Platform.displayCaps.platformWidth 768 [INFO] : Ti.Platform.displayCaps.logicalDensityFactor 1 [INFO] : screen: 768 1024 [INFO] : Alloy.Globals.Style {"ScreenWidth":768,"ScreenHeight":1024,"FontSize":18,"RoundButtonWidth":538,"RoundButtonWidthSmall":192,"RoundButtonHeight":57.6,"RoundButtonFontSize":23,"RoundButtonBorderRadius":15,"RoundButtonBorderWidth":5,"RoundButtonInGroupWidth":461,"RoundButtonTextColor":"#1a4b73","RoundButtonDisabledColor":"#a0a0a0","ButtonColor":"#e3e3e3","HeaderColor":"#6cc0e9","SelectedColor":"#e5e5e5","FriendsLabelColor":"#0094ae","ButtonBackgroundGradient":{"type":"linear","colors":["#f3f3f3","#a3a3a3"]},"TitleFontSize":26,"RightArrowFontSize":30,"AppTitleFontSize":60,"QuestionFontSize":42,"CellWidth":144,"TableViewWidth":432,"ArrowGap":58,"TableViewTextWidth":374,"SmallRowViewTextWidth":480,"TableViewListWidth":470,"ProgressWidth":753,"ProgressHeight":47,"RefreshPullHeight":1024,"RefreshPullTop":-1023,"TextFieldWidth":614,"TextFieldHeight":61.44,"p1":5,"p2":10,"p3":14,"p4":19,"p5":24,"p6":29,"p7":34,"p8":38,"p9":43,"p10":48,"p15":72,"p20":96,"p30":144,"p40":192,"p50":240,"p60":288,"p70":336} [INFO] : registration successful [INFO] : accountlink successful. user data:{"id":"5511139a7eead2057ea18058","created_at":"2015-03-24T07:34:50+0000","updated_at":"2015-03-24T07:34:50+0000","external_accounts":[{"external_id":"10203290489877651","external_type":"facebook","token":"CAAUrUQLp8NsBAJWFMfoPWf0TzpCCyxXhriYr60YZCyTLXIHmxCCzMKQ8nBvmNjRXyaxsB1fMD5aZBfmcVFerAsJ4ZA4ZCd1ZBHcWD3qNtAJdBJdJyJqeghVJd3xYhdZBt0Ew70WrGZBX3kA3OG8dsw37YrtZApehgmPI9c2BzdjR0YSW83YtKvsEHWRIxkxGpvGClpcMnHyR1q3324mM3kGIOw4jZBmbUG0WF5QWB6OoXzgZDZD"}],"confirmed_at":"2015-03-24T07:34:50+0000","username":"test","email":"","admin":"false","stats":{"photos":{"total_count":0},"storage":{"used":0}},"friend_counts":{"requests":0,"following":0,"friends":0,"followers":0}} [INFO] : searchFacebookFriends not successful [INFO] : Error: [INFO] : User is not authorized with facebookAlex