Accessing user_metadata with social sign up

Hello! I enabled social sign up with Google and Microsoft, but I am not able to access first and last name in user_metadata. Here’s what I’m trying:

lock.getUserInfo(authResult.accessToken, function(error, profile) {
    if (!error) {

I get the following

  sub: "google-oauth2|xxx",
  email: "", 
  email_verified: true

and if I try to use a rule to add a new property to user.user_metadata I get ‘Wrong credentials’ error. There’s another rule that adds user_metadata to a idTokenPayload property which contains first and last name ( the lock includes email, password, first and last name), but it’s only added when I sign up with username and password. Is there a way to get first and last name from social providers?

Hi @peter.koev,

Can you share all of your lock code? I am guessing you are missing the profile scope.

You’re correct! I hadn’t included the profile scope, but it’s in now. Thanks for the help!

1 Like

Glad it was an easy fix! Let us know if you have any other questions. :smile:

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.