[SOLVED] Meteor.loginWithFacebook - custom image size?


#1

Hey guys,

Just set up loginWithFacebook following the awesome guide, but one thing I cannot seem to figure out is how ask for a custom (bigger) profile picture size, at the moment 50x50 px is returned.

Desired results is a bigger image, or ideally a solution that, again, let’s me specify size.

Cheers


#2

Use the form
http://graph.facebook.com/ + facebook.id + “/picture/?type=large” on create user hook or while parsing facebook response.


#3

Sorry, not sure I understand, could you please elaborate?

This is how the call looks on front end:

  Meteor.loginWithFacebook(
      { requestPermissions: ["public_profile", "email"] },
      function(err) {
        if (err) {
          console.log("Handle errors here: ", err);
        } else {
          history.push(`/`);
          client.reFetchObservableQueries();
        }
      }
    );
  };

This is how the hook looks like:

Accounts.onCreateUser(function(options, user) {
  if (!user.services.facebook) {
    return user;
  }

  const { facebook } = user.services;

  user.emails = [{ address: facebook.email }];
  user.profile = {
    [..]
    picture: facebook.picture["data"]["url"]
  };

  return user;
});

and this is what the response looks like:


I20180911-19:23:55.525(-4)? { accessToken: '...',
[..]
I20180911-19:23:55.686(-4)?   picture:
I20180911-19:23:55.686(-4)?    { data:
I20180911-19:23:55.686(-4)?       { height: 50,
I20180911-19:23:55.687(-4)?         is_silhouette: false,
I20180911-19:23:55.687(-4)?         url: 'https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=1874165786036399&height=50&width=50&ext=1539300235&hash=AeQCT6MVNVpqYd7c',
I20180911-19:23:55.687(-4)?         width: 50 } },
I20180911-19:23:55.687(-4)?   short_name: 'Scott' }

Where would the snippet you’ve provided go?


#4

Sorry, wasn’t clear enough. Here you go.

Accounts.onCreateUser(function(options, user) {
  if (!user.services.facebook) {
    return user;
  }

  const { facebook } = user.services;

  user.emails = [{ address: facebook.email }];
  user.profile = {
    [..]
    //picture: facebook.picture["data"]["url"],
    picture: `http://graph.facebook.com/` + facebook.id + "/picture/?width=300",
  };

  return user;
});


#5

This works, thank you sir!