Sunday, September 23, 2012

ACS Social Integration

Do you know, How to create ACS cloud user account using Facebook login?
Yes, we can do using ACS Social Integrations.

The external account login will create a ACS Services account if it hasn't been created, otherwise, it will login using the user who has the matching external account info.

STEP 1 - Facebook login in Titanium App 
Use below sample code for Facebook login

STEP 2 - Social Integration
After successfull login with Facebook, you will get Facebook accessToken, you can retrive this token using "Ti.Facebook.accessToken".

To integrate your facebook account with cloud, you need to pass three parameters to "Cloud.SocialIntegrations.externalAccountLogin" method,

id - External account's user id, optional for facebook. ACS server will obtain the uid using facebook token if id is missing
type - Type of the external account social media like Facebook, LinkedIn, Twitter(Currently only facebook token will be validated by the ACS server)
token - Token provided by the external account
add SocialIntegrations in Facebook login event listener

After the successful ACS Social Integrations go to -> ypou-app -> Manage ACS -> Development -> Users
Here you will find a new cloud user account, which was created by external account login.

Other Methods
externalAccountLink - Associate an external account with an existing Appcelerator Cloud Services user account

externalAccountUnlink - Disassociate an external account from a Appcelerator Cloud Services user account.

searchFacebookFriends - Retrieves a list of Facebook Friends



  1. That was very helpful :)

    Any idea how to publish to a Stream given I have the all the account info:id / type / token? Would that require me to make my own javascript call?

  2. Hi Joe,
    You can use Ti.Facebook.requestWithGraphPath, for that you need to call Facebook Graph API call.

    Refer this link for more info!/api/Titanium.Facebook

  3. Splendid! Thanks Again :)

  4. How can I change the URL of this application, so that I can login an account on a different webpage?
    The webpage I want to login is:

  5. Sorry, I can't understand. What do you mean "URL of this application"

  6. I want to login to an account in this web page and I want to make an application to login to an account in this web page: l want to use this code but I want to change the web address so that instead of logging into Facebook I could login to an account in the previous web page.

  7. I want to use this code to login to a web page other than facebook, to be exact, I want to login to this web page: That's what I mean by a different URL, its a different web page.
    Thanks in advance!

  8. I don't think ACS social integration will support external site(
    As per the documentation "external account social media like Facebook, LinkedIn, Twitter(Currently only facebook token will be validated by the ACS server)"

  9. Is there a way it can detect if they are already logged in with FB and it can use their current information rather than asking for them to log in to FB again?

  10. Hi,
    You can check whether user logged in with FB using "Titanium.Facebook.loggedIn", it will retrieve boolean value

    also, You can check whether cloud user logged in using "Cloud.hasStoredSession( )"

  11. Thanks for a quick reply. I'll see if I can integrate this.

  12. Thanks, I used Cloud.hasStoredSession( ) to see if they've already registered. How do I populate the user fields in the ACS DB with their email, name, etc.?

  13. Hi,
    i.m trying to execute facebook login to my app.
    Titanium.Facebook.appid you entered is our titanium appkey or else facebook app id..?

  14. Hey when i use the code in step 1, it throws an error " Couldn`t find module ""

  15. It does check for facebook permission in web browser and when it returns to app the it throws this error