How do you integrate the Parse Javascript API with Appcelerator and not use undocumented calls?
Asked Answered
O

1

63

I would like to create a user from his/her Facebook credentials without using undocumented calls. I do not believe it is possible based on the current implementation of Parse Javascript Library for two known reasons:

1. The current implementation of the library does not support the Appcelerator HTTP client so it fails immediately. I have addressed this issue by extending the existing Parse Javascript library's ajax method to utilize the Appcelerator HTTP client.

http://www.clearlyinnovative.com/blog/post/34758524107/parse-appcelerator-titanium-the-easy-way

There has been approximately 2K views on the slide deck I created and about the same on the blog post, so it is pretty clear to me people want this to work.

2. The current implementation of the library assumes you are integrating with the Facebook Javascript library and that library does not work with Appcelerator either. In fact Appcelerator has integrated Facebook directly into the framework so there is no need for the javascript library. All of the information required to link a user account to Facebook can be easily gotten using the API calls that Appcelerator developers are already familiar with.

The original question was removed from the Parse Support forum so I am looking for a solution from a wider community.

Hi Aaron,

It's not helpful to other developers to promote using undocumented APIs in the Parse library as a workaround, so I make the decision to unlist it. I understand it might help in your particular case with Titanium, and you're well aware of the implications of using private APIs, but other users might overlook that warning. I hope you understand.

Héctor Ramos Solutions Architect, Parse https://parse.com/help

This is the code that was too dangerous to be left visible on the forum:

// setting auth data retrieved from Ti.Facebook login
authData = {
    "facebook" : {
        "id" : Ti.Facebook.uid,
         "access_token" : Ti.Facebook.accessToken,
         "expiration_date" : expDate, // "format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
    }
};

// Either way I resolved the problem, calling _handleSaveResult(true) on the returned user object, 
// I just dont think it should have been as difficult as it was
// attempt to log the user in using the FB information
var user = new Parse.User();
user.save({
    "authData" : authData
}).then(function(_user) {
    // force the user to become current
    _user._handleSaveResult(true); //<-- this is the evil method I called
    if (!_user.existed()) {

        // add additional user information
        var userInfo = {
            "acct_email" : "[email protected]",
            "acct_fname" : "Bryce",
            "acct_lname" : "Saunders"
        };
        return _user.save(userInfo);
    }
}).then(function(_user) {

    alert('Hooray! Let them use the app now.');

}, function(error) {
    alert(' ERROR: ' + JSON.stringify(error, null, 2));
});

Question on Appcelerator Forum

http://developer.appcelerator.com/question/152146/facebook-appcelerator-and-parse-integration-need-help

Question on Parse Forum

https://parse.com/questions/how-do-you-integrate-the-parse-javascript-api-with-appcelerator-and-not-use-undocumented-calls

Orelle answered 10/5, 2013 at 11:58 Comment(6)
What's your issue? It seems you've answered or worked around all the issues.Sestina
it is supported and can change at any time with an update to the parse.js libraryOrelle
Emailed their exec staff yet? It seems like until they change which APIs are officially exposed and give a way for this to work, you're stuck without an "answer".Sestina
They aaid they were investigating over a month ago but still have blocked my response on their forum and I haven't gotten and official answer. I just don't use Parse and don't recommend it until they show some Appcelerator love.Orelle
@AaronSaunders don't expect much love given that FB acquired ParseRousing
I have given up hope and encourage people to use appcelerator cloud services, stackmob or kinveyOrelle
P
2

Maybe this part of a newer SDK, but can't you just call:

Parse.FacebookUtils.logIn({
  "facebook": {
    "id": "user's Facebook id number as a string",
    "access_token": "an authorized Facebook access token for the user",
    "expiration_date": "token expiration date of the format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
   },
   {
      success : function(_user) {},
      error : function(_user, error) {}
   }
};

It's not documented in the Javascript guide, but it is documented in the unminified version of the code visa vie:

@param {String, Object} permissions The permissions required for Facebook
log in.  This is a comma-separated string of permissions.
Alternatively, supply a Facebook authData object as described in our
REST API docs if you want to handle getting facebook auth tokens
yourself.

I made some updates to your original code to support the lastest SDK which I'm going to publish on Github.

Thanks so much for spearheading this effort. Your original post saved me hours.

Prescript answered 7/9, 2013 at 16:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.