title: Retrieving Facebook Profile Picture URL
body: <p>I am using satellizer for authentication in a MEAN app. After auth is complete i want to get the profile picture of the user. The following is my code.</p>
  
  <p><strong>Angular Controller</strong> </p>
  
  <pre><code>(function(){
      'use strict';
      angular
          .module('nayakans07')
          .controller('RegisterController', registerController);
  
      function registerController ($scope, $auth) {
  
          $scope.authenticate = function (provider) {
              $auth.authenticate(provider)
                  .then(function (res) {
                      console.log(res);
                  }, authErrorHandler);
          };
  
          function authErrorHandler (err) {
              console.log(err);
          }
      }
  
  })();
  </code></pre>
  
  <p><strong>Node.js Route Handler</strong></p>
  
  <pre><code>(function () {
      'use strict';
  
      var request = require('request');
      var qs = require('querystring');
      var tokenHelper = require('../helpers/tokenHelper.js');
      var config = require('../config/configuration.js');
      var Member = require('../models/memberModel.js');
  
      module.exports = function (req, res) {
          var accessTokenUrl = 'https://graph.facebook.com/oauth/access_token';
          var grapApiProfileUrl = 'https://graph.facebook.com/me';
          var graphApiProfileImageUrl = 'https://graph.facebook.com/me/picture?width=250&amp;json=true';
  
          var params = {
              client_id: req.body.clientId,
              redirect_uri: req.body.redirectUri,
              code: req.body.code,
              client_secret: config.FACEBOOK_SECRET
          };
  
          request.get({
              url: accessTokenUrl,
              qs: params
          }, function (err, response, accessToken) {
              accessToken = qs.parse(accessToken);
              request.get({
                  url: grapApiProfileUrl,
                  qs: accessToken,
                  json: true
              }, function (err, response, profile) {
                  console.log(profile);
                  Member.findOne({
                      facebookId: profile.id
                  }, function (err, existingMember) {
                      if (existingMember) {
                          return res.status(200).send({
                              user: existingMember,
                              token: tokenHelper.createToken(existingMember, req, res)
                          });
                      } else {
                          request.get({
                              url: graphApiProfileImageUrl,
                              qs: accessToken,
                          }, function (err, response, profileImage) {
                              console.log(profileImage);
                              var fbData = {
                                  facebookId: profile.id,
                                  fullName: profile.name,
                                  email: profile.email,
                                  profileImage: profileImage
                              };
                              return res.status(200).send(fbData);
                          });
                      }
                  });
              });
          });
      };
  
  
  })();
  </code></pre>
  
  <p>After i get the access token from facebook i call the <code>https://graph.facebook.com/me/picture?width=250&amp;json=true</code> endpoint with the access token to get the profile pic link. In the <a href="https://developers.facebook.com/tools/explorer/?method=GET&amp;path=me%2Fpicture%3Fwidth%3D250%26json%3Dtrue%26redirect%3Dtrue&amp;version=v2.4" rel="nofollow">Facebook's API Explorer</a> calling the same endpoint with the token i get the profile image url but when i call it from node.js endpoint handler i get some binary like data. part of the response is here.</p>
  
  <pre><code>����JFIF���Photoshop 3.08BIM�gtc2XjTON-90Jqu9JFj83(bFBMD01000ac0030000b909000069110000fe120000dc14000069190000c02400002326000029280000872a0000fd3e0000��ICC_PROF
  </code></pre>
  
  <p>How can i get the URL for the profile image instead of this response.</p>