Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get full size facebook picture profile in Cognito user pool attribute

How can I get facebook full-size profile picture in Cognito User Pool attribute mappings.

I have mapped the Facebook attribute "picture" to Cognito User pool attribute "Picture" but the problem is that facebook is returning a picture of 50x50. I don't know how to specify the resolution in Cognito.

picture returned by facebook:

{ 
   data: {
     height: 50,
     is_silhouette: false,
     url: <URL of profile picture>,
     width: 50 
    }
}
like image 971
niqui Avatar asked Mar 20 '18 13:03

niqui


1 Answers

I found a way to do this. It's a bit of effort but it works.

  1. In cognito map the access_token to some unused user pool attribute. I mapped it to profile
  2. Add a post confirmation lambda trigger. The lamdba should receive an event which will have a user pool attribute profile set to the facebook access token of the logged in user. The lambda should then;
  • Use this access token to get a profile picture of any size you want form the Facebook api like this.
  • Use this cognito endpoint to update the user attributes with the profile picture returned from Facebook. You can also remove the profile attribute as you probably don't want to actually store the users Facebook access token in cognito.
like image 67
Simon Verhoeven Avatar answered Nov 06 '22 21:11

Simon Verhoeven