Created
August 30, 2012 19:05
-
-
Save vseventer/3537809 to your computer and use it in GitHub Desktop.
Facebook authentication with Kinvey.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Initialize the Facebook SDK. | |
| FB.init({ | |
| appId: '<your-app-id>', | |
| oauth: true | |
| /* additional properties */ | |
| }); | |
| // Open login popup. | |
| FB.login(function(response) { | |
| if(response.authResponse) { | |
| // Login user at Kinvey. | |
| new Kinvey.User().loginWithFacebook(response.authResponse.accessToken, { | |
| success: function(user) { | |
| // User is now both a Facebook and Kinvey user. | |
| console.log(user.getIdentity());// Logs Facebook identity. | |
| }, | |
| error: function() { | |
| // An error occurred. | |
| } | |
| }); | |
| } | |
| else { | |
| // User cancelled login or did not fully authorize. | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment