Ads

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
https://my.appcelerator.com/apps -> 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

References: 
http://docs.appcelerator.com/titanium/2.1/index.html#!/api/Titanium.Cloud.SocialIntegrations
https://cloud.appcelerator.com/docs/api/v1/social/loginexternal

15 comments:

  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?

    ReplyDelete
  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 http://docs.appcelerator.com/titanium/2.1/index.html#!/api/Titanium.Facebook

    ReplyDelete
  3. Splendid! Thanks Again :)

    ReplyDelete
  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:
    https://www.4life.com/login/default.aspx

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

    ReplyDelete
  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: www.4life.com/login/default.aspx. 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.

    ReplyDelete
  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: https://www.4life.com/login/default.aspx. That's what I mean by a different URL, its a different web page.
    Thanks in advance!

    ReplyDelete
  8. I don't think ACS social integration will support external site(https://www.4life.com/login/default.aspx).
    As per the documentation "external account social media like Facebook, LinkedIn, Twitter(Currently only facebook token will be validated by the ACS server)"

    ReplyDelete
  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?

    ReplyDelete
  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( )"

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

    ReplyDelete
  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.?

    ReplyDelete
  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..?

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

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

    ReplyDelete