DF2.0, AngularJS, OAuth

Hi - Does anybody have tutorial on how to handle OAuth in Angular with DF 2.0?

I make the call to /api/v2/user/session?service=facebook, it redirects to facebook. All good.

Once my credentials are verified on Facebook, I get redirected back to my app. I don’t know how to handle the return URL in AngularJS so that I can make the final call to my server and get the user details.

Help please!

Don’t know about Angular but here is how you would this using jQuery. Hope this gives you some pointer to how you would do this in Angular.

This script should execute after you are redirected back to your app from Facebook.

// Extract the query string from the URL that Facebook used to redirect back your app.
// This is pure JavaScript and should work in your Angular environment. 
// But there might be a better way to do this in Angular.

var queryString = location.search.substring(1);

// Now make a simple POST call with the extracted query string 
// to your DreamFactory 2.0 instance.
// Here I am using jQuery to make this Ajax call. 
// So, use your Angular equivalent for this.

if(queryString) {
            url: 'http://instance/api/v2/user/session?oauth_callback=true&'+queryString,
            type: 'POST',
            beforeSend: function (xhr) {

                success: function (json) {
                   // Save this token in your app and use this to make all other calls.
                   var token = json.session_token;
                error: function (err) {
1 Like