Customizing facebook auth


#1

Hi, i’m trying to customize the my own facebook auth based on the facebookauthentication template, but the process has been difficult. I’m trying to add first_name, last_name, gender, and pictureUrl along with the already provided email. I didn’t think it would be that complicated. Can you tell me if I did anything wrong. full graphcool server repo here

I’ve changed the FacebookUser interface to accommodate the new fields

interface FacebookUser {
id: string
email: string | null
first_name: string | null
last_name: string | null
gender: string | null
picture: any | null
}

i’ve changed the endpoints to call for additional data in getFacebookUser:

const endpoint = "https://graph.facebook.com/v2.11/me?fields=id%2Cpicture%2Cemail%2Cfirst_name%2Clast_name%2Cgender&access_token=${facebookToken}"

and I customized createGraphcoolUser like so

async function createGraphcoolUser(api: GraphQLClient, facebookUser: FacebookUser): Promise {
const mutation = …
const variables = {
facebookUserId: facebookUser.id,
email: facebookUser.email,
firstName: facebookUser.first_name,
lastName: facebookUser.last_name,
gender: facebookUser.gender,
profilePic: facebookUser.picture.data.url,
}

return api.request<{ createUser: User }>(mutation, variables)
    .then(r => r.createUser.id)

}


#2

the profile picture url was the problem