Search code examples
javascriptfacebookfacebook-graph-apifirebase-authenticationfirebaseui

How to get user_likes after firebaseauth-ui call is successful with user_likes permission approved on facebook


I am working on a login flow with FirebaseUI for web. Facebook provider is invoked with scope(permission) user_likes. After user approves the app and permissions, login is successful.

However, I am now wondering how to retrieve the user_likes via a graph API call to facebook directly. Essentially, where to retrieve the required parameters from successful firebase auth so as to make a successful graph api retrieving user_likes list.


Solution

  • You need to get the facebook auth credential from the signInSuccess callback. You can then use the OAuth credential to query the facebook api:

    'callbacks': {
          'signInSuccess': function(currentUser, credential, redirectUrl) {
            // Do something.
            // Return type determines whether we continue the redirect automatically
            // or whether we leave that to developer to handle.
            // Credential is in credential.accessToken
            return false;
          }
        }