Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amplify Federated Sign In not returning Email for Facebook #8823

Closed
3 tasks done
geeshans opened this issue Aug 30, 2021 · 9 comments
Closed
3 tasks done

Amplify Federated Sign In not returning Email for Facebook #8823

geeshans opened this issue Aug 30, 2021 · 9 comments
Assignees
Labels
Auth Related to Auth components/category OAuth For issues related to OAuth pending-response Issue is pending response from the issue requestor

Comments

@geeshans
Copy link

geeshans commented Aug 30, 2021

Before opening, please confirm:

JavaScript Framework

Angular

Amplify APIs

Authentication

Amplify Categories

auth

Environment information

npx: installed 1 in 2.603s

  System:
    OS: macOS 11.4
    CPU: (8) x64 Apple M1
    Memory: 41.16 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.4 - /usr/local/bin/node
    Yarn: 1.22.11 - /usr/local/bin/yarn
    npm: 6.14.14 - /usr/local/bin/npm
  Browsers:
    Chrome: 92.0.4515.159
    Safari: 14.1.1
  npmPackages:
    @angular-devkit/build-angular: ~0.1100.1 => 0.1100.1 
    @angular/animations: ~11.0.0 => 11.0.0 
    @angular/animations/browser:  undefined ()
    @angular/animations/browser/testing:  undefined ()
    @angular/cdk: ~11.0.0 => 11.0.0 
    @angular/cdk/a11y:  undefined ()
    @angular/cdk/accordion:  undefined ()
    @angular/cdk/bidi:  undefined ()
    @angular/cdk/clipboard:  undefined ()
    @angular/cdk/coercion:  undefined ()
    @angular/cdk/collections:  undefined ()
    @angular/cdk/drag-drop:  undefined ()
    @angular/cdk/keycodes:  undefined ()
    @angular/cdk/layout:  undefined ()
    @angular/cdk/observers:  undefined ()
    @angular/cdk/overlay:  undefined ()
    @angular/cdk/platform:  undefined ()
    @angular/cdk/portal:  undefined ()
    @angular/cdk/scrolling:  undefined ()
    @angular/cdk/stepper:  undefined ()
    @angular/cdk/table:  undefined ()
    @angular/cdk/testing:  undefined ()
    @angular/cdk/testing/protractor:  undefined ()
    @angular/cdk/testing/testbed:  undefined ()
    @angular/cdk/text-field:  undefined ()
    @angular/cdk/tree:  undefined ()
    @angular/cli: ~11.0.1 => 11.0.1 
    @angular/common: ~11.0.0 => 11.0.0 
    @angular/common/http:  undefined ()
    @angular/common/http/testing:  undefined ()
    @angular/common/testing:  undefined ()
    @angular/common/upgrade:  undefined ()
    @angular/compiler: ~11.0.0 => 11.0.0 (9.0.0)
    @angular/compiler-cli: ~11.0.0 => 11.0.0 
    @angular/compiler/testing:  undefined ()
    @angular/core: ~11.0.0 => 11.0.0 (9.0.0)
    @angular/core/testing:  undefined ()
    @angular/flex-layout: ^11.0.0-beta.33 => 11.0.0-beta.33 
    @angular/flex-layout/core:  undefined ()
    @angular/flex-layout/extended:  undefined ()
    @angular/flex-layout/flex:  undefined ()
    @angular/flex-layout/grid:  undefined ()
    @angular/flex-layout/server:  undefined ()
    @angular/forms: ~11.0.0 => 11.0.0 
    @angular/language-service: ~11.0.0 => 11.0.0 
    @angular/material: ^11.0.0 => 11.0.0 
    @angular/material/autocomplete:  undefined ()
    @angular/material/autocomplete/testing:  undefined ()
    @angular/material/badge:  undefined ()
    @angular/material/badge/testing:  undefined ()
    @angular/material/bottom-sheet:  undefined ()
    @angular/material/bottom-sheet/testing:  undefined ()
    @angular/material/button:  undefined ()
    @angular/material/button-toggle:  undefined ()
    @angular/material/button-toggle/testing:  undefined ()
    @angular/material/button/testing:  undefined ()
    @angular/material/card:  undefined ()
    @angular/material/card/testing:  undefined ()
    @angular/material/checkbox:  undefined ()
    @angular/material/checkbox/testing:  undefined ()
    @angular/material/chips:  undefined ()
    @angular/material/chips/testing:  undefined ()
    @angular/material/core:  undefined ()
    @angular/material/core/testing:  undefined ()
    @angular/material/datepicker:  undefined ()
    @angular/material/datepicker/testing:  undefined ()
    @angular/material/dialog:  undefined ()
    @angular/material/dialog/testing:  undefined ()
    @angular/material/divider:  undefined ()
    @angular/material/divider/testing:  undefined ()
    @angular/material/expansion:  undefined ()
    @angular/material/expansion/testing:  undefined ()
    @angular/material/form-field:  undefined ()
    @angular/material/form-field/testing:  undefined ()
    @angular/material/form-field/testing/control:  undefined ()
    @angular/material/grid-list:  undefined ()
    @angular/material/grid-list/testing:  undefined ()
    @angular/material/icon:  undefined ()
    @angular/material/icon/testing:  undefined ()
    @angular/material/input:  undefined ()
    @angular/material/input/testing:  undefined ()
    @angular/material/list:  undefined ()
    @angular/material/list/testing:  undefined ()
    @angular/material/menu:  undefined ()
    @angular/material/menu/testing:  undefined ()
    @angular/material/paginator:  undefined ()
    @angular/material/paginator/testing:  undefined ()
    @angular/material/progress-bar:  undefined ()
    @angular/material/progress-bar/testing:  undefined ()
    @angular/material/progress-spinner:  undefined ()
    @angular/material/progress-spinner/testing:  undefined ()
    @angular/material/radio:  undefined ()
    @angular/material/radio/testing:  undefined ()
    @angular/material/select:  undefined ()
    @angular/material/select/testing:  undefined ()
    @angular/material/sidenav:  undefined ()
    @angular/material/sidenav/testing:  undefined ()
    @angular/material/slide-toggle:  undefined ()
    @angular/material/slide-toggle/testing:  undefined ()
    @angular/material/slider:  undefined ()
    @angular/material/slider/testing:  undefined ()
    @angular/material/snack-bar:  undefined ()
    @angular/material/snack-bar/testing:  undefined ()
    @angular/material/sort:  undefined ()
    @angular/material/sort/testing:  undefined ()
    @angular/material/stepper:  undefined ()
    @angular/material/stepper/testing:  undefined ()
    @angular/material/table:  undefined ()
    @angular/material/table/testing:  undefined ()
    @angular/material/tabs:  undefined ()
    @angular/material/tabs/testing:  undefined ()
    @angular/material/toolbar:  undefined ()
    @angular/material/toolbar/testing:  undefined ()
    @angular/material/tooltip:  undefined ()
    @angular/material/tooltip/testing:  undefined ()
    @angular/material/tree:  undefined ()
    @angular/material/tree/testing:  undefined ()
    @angular/platform-browser: ~11.0.0 => 11.0.0 
    @angular/platform-browser-dynamic: ~11.0.0 => 11.0.0 
    @angular/platform-browser-dynamic/testing:  undefined ()
    @angular/platform-browser/animations:  undefined ()
    @angular/platform-browser/testing:  undefined ()
    @angular/router: ~11.0.0 => 11.0.0 
    @angular/router/testing:  undefined ()
    @angular/router/upgrade:  undefined ()
    @angular/service-worker: ~11.0.0 => 11.0.0 
    @angular/service-worker/config:  undefined ()
    @aws-amplify/cli: ^4.32.0 => 4.32.1 
    @aws-amplify/ui-angular: ^0.4.11 => 0.4.11 
    @ngx-translate/core: ^13.0.0 => 13.0.0 
    @ngx-translate/http-loader: ^6.0.0 => 6.0.0 
    @types/jasmine: ~3.6.0 => 3.6.1 
    @types/jasminewd2: ~2.0.3 => 2.0.8 
    @types/node: ^12.11.1 => 12.12.62 
    angular-x-image-viewer: ^2.0.1 => 2.0.1 
    assert:  1.0.0 
    aws-amplify: ^3.3.7 => 3.3.8 
    aws-appsync: ^4.0.1 => 4.0.1 
    codelyzer: ^6.0.0 => 6.0.1 
    example-typescript:  1.0.0 
    expect.js:  0.3.1 
    grapesjs: ^0.16.34 => 0.16.34 
    grapesjs-mjml: ^0.5.2 => 0.5.2 
    grapesjs-preset-newsletter: ^0.2.20 => 0.2.20 
    grapesjs-preset-webpage: ^0.1.11 => 0.1.11 
    graphql: ^15.4.0 => 15.4.0 (14.0.0, 14.7.0, 0.13.0)
    graphql-tag: ^2.11.0 => 2.11.0 (2.10.1)
    jasmine-core: ~3.6.0 => 3.6.0 (2.8.0)
    jasmine-spec-reporter: ~5.0.0 => 5.0.2 
    karma: ~5.1.1 => 5.1.1 
    karma-chrome-launcher: ~3.1.0 => 3.1.0 
    karma-coverage-istanbul-reporter: ~3.0.2 => 3.0.3 
    karma-jasmine: ~4.0.0 => 4.0.1 
    karma-jasmine-html-reporter: ^1.5.0 => 1.5.4 
    lib:  0.0.1 
    localforage: ^1.9.0 => 1.9.0 
    moment: ^2.29.1 => 2.29.1 
    new-plugin-package:  1.0.0 
    ng-packagr: ^11.0.2 => 11.0.2 
    ngx-doc-viewer: ^1.4.1 => 1.4.1 
    ngx-translate-multi-http-loader: ^3.0.0 => 3.0.0 
    node-example:  1.0.0 
    protractor: ~7.0.0 => 7.0.0 
    protractor-example:  1.0.0 
    rxjs: ~6.6.3 => 6.6.3 
    rxjs-compat: ^6.6.3 => 6.6.3 
    rxjs/ajax:  undefined ()
    rxjs/fetch:  undefined ()
    rxjs/internal-compatibility:  undefined ()
    rxjs/operators:  undefined ()
    rxjs/testing:  undefined ()
    rxjs/webSocket:  undefined ()
    ts-node: ~7.0.0 => 7.0.1 (8.10.2)
    tslib: ^2.0.0 => 2.0.1 (2.0.3, 1.14.1, 1.13.0, 1.10.0)
    tslint: ~6.1.0 => 6.1.3 
    typescript: ~4.0.5 => 4.0.5 (3.9.7)
    typescript-example:  1.0.0 
    zone.js: ~0.10.2 => 0.10.3 
  npmGlobalPackages:
    @angular/cli: 12.2.1
    @aws-amplify/cli: 5.3.0
    aws-cdk: 1.119.0
    cms-cdk: 0.1.0
    npm: 6.14.14
    typescript: 4.3.5
    yarn: 1.22.11

Describe the bug

I'm using Amplify to add social signing to a webpage and with google I'm getting the email of the user but it's missing in facebook.

I have printed the event received by "Pre sign-up" Lambda and user email is not returned.

{
    "version": "1",
    "region": "us-east-1",
    "userPoolId": "us-east-xxxxxx",
    "userName": "Facebook_123456",
    "callerContext": {
        "awsSdkVersion": "aws-sdk-unknown-unknown",
        "clientId": "123456abcd"
    },
    "triggerSource": "PreSignUp_ExternalProvider",
    "request": {
        "userAttributes": {
            "email_verified": "false",
            "cognito:email_alias": "",
            "phone_number_verified": "false",
            "cognito:phone_number_alias": ""
        },
        "validationData": {}
    },
    "response": {
        "autoConfirmUser": false,
        "autoVerifyEmail": false,
        "autoVerifyPhone": false
    }
}

Expected behavior

Receive "email" as part of the userAttributes.

Reproduction steps

  1. Add the button to login via facebook
<div class="d-flex justify-content-center align-items-center">
  <amplify-authenticator>
    <amplify-sign-in  slot="sign-in" >
        <amplify-facebook-button  slot="federated-buttons" (click)="federatedSignIn('facebook')" >Facebook</amplify-facebook-button>
        <amplify-google-button slot="federated-buttons" (click)="federatedSignIn('google')" >Google</amplify-google-button>
    </amplify-sign-in>
  </amplify-authenticator>
</div>
  1. Add the typescript function
import Auth, { CognitoHostedUIIdentityProvider } from '@aws-amplify/auth'
...

  federatedSignIn(provider: any): void {
    switch (provider) {
      case 'facebook':
          console.log("Authenticating using Facebook");
          Auth.federatedSignIn({ provider: CognitoHostedUIIdentityProvider.Facebook });
          break;
      case 'google':
        console.log("Authenticating using Google");
        Auth.federatedSignIn({ provider: CognitoHostedUIIdentityProvider.Google });
        break;
    }
     
  }

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


aws-exports.js

No response

Manual configuration

    const userpoolProviderFacebook = new cognito.UserPoolIdentityProviderFacebook(this, 'facebook-provider',{
      clientId: this.facebookClientId.secretValue.toString(),
      clientSecret: this.facebookClientSecret.secretValue.toString(),
      userPool: userpool,
      scopes: ['public_profile','email'],
      attributeMapping: {
        preferredUsername: {
          attributeName: cognito.ProviderAttribute.FACEBOOK_ID.attributeName,
        },
        email: {
          attributeName: cognito.ProviderAttribute.FACEBOOK_EMAIL.attributeName,
        }
      }
    });

Additional configuration

{
    "UserPool": {
        "Id": "yyyy_xxxxxx",
        "Name": "example",
        "Policies": {
            "PasswordPolicy": {
                "MinimumLength": 6,
                "RequireUppercase": false,
                "RequireLowercase": false,
                "RequireNumbers": false,
                "RequireSymbols": false,
                "TemporaryPasswordValidityDays": 3
            }
        },
        "LambdaConfig": {
            "PreSignUp": "arn:aws:lambda:xxxxxxx-pre-signup"
        },
        "LastModifiedDate": "xxxx",
        "CreationDate": "xxxx",
        "SchemaAttributes": [
            {
                "Name": "sub",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": false,
                "Required": true,
                "StringAttributeConstraints": {
                    "MinLength": "1",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "given_name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "family_name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "middle_name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "nickname",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "preferred_username",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "profile",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "picture",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "website",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "email",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "email_verified",
                "AttributeDataType": "Boolean",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false
            },
            {
                "Name": "gender",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "birthdate",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "10",
                    "MaxLength": "10"
                }
            },
            {
                "Name": "zoneinfo",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "locale",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "phone_number",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "phone_number_verified",
                "AttributeDataType": "Boolean",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false
            },
            {
                "Name": "address",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "updated_at",
                "AttributeDataType": "Number",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "NumberAttributeConstraints": {
                    "MinValue": "0"
                }
            },
            {
                "Name": "identities",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {}
            }
        ],
        "AutoVerifiedAttributes": [
            "email"
        ],
        "UsernameAttributes": [
            "email"
        ],
        "SmsVerificationMessage": "The verification code to your new account is {####}",
        "EmailVerificationMessage": "The verification code to your new account is {####}",
        "EmailVerificationSubject": "Verify your new account",
        "VerificationMessageTemplate": {
            "SmsMessage": "The verification code to your new account is {####}",
            "EmailMessage": "The verification code to your new account is {####}",
            "EmailSubject": "Verify your new account",
            "DefaultEmailOption": "CONFIRM_WITH_CODE"
        },
        "MfaConfiguration": "OFF",
        "EstimatedNumberOfUsers": 5,
        "EmailConfiguration": {
            "EmailSendingAccount": "COGNITO_DEFAULT"
        },
        "UserPoolTags": {},
        "Domain": "example-domain",
        "AdminCreateUserConfig": {
            "AllowAdminCreateUserOnly": true,
            "UnusedAccountValidityDays": 3
        },
        "Arn": "arn:aws:cognito-idp:xxxxx:userpool/yyyy_xxxxxxx",
        "AccountRecoverySetting": {
            "RecoveryMechanisms": [
                {
                    "Priority": 1,
                    "Name": "verified_phone_number"
                },
                {
                    "Priority": 2,
                    "Name": "verified_email"
                }
            ]
        }
    }
}

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

@jamesaucode jamesaucode added pending-triage Issue is pending triage Auth Related to Auth components/category labels Aug 30, 2021
@chrisbonifacio chrisbonifacio self-assigned this Aug 31, 2021
@chrisbonifacio chrisbonifacio added this to Pending Triage in Issues Triaging via automation Aug 31, 2021
@chrisbonifacio chrisbonifacio added investigating This issue is being investigated and removed pending-triage Issue is pending triage labels Aug 31, 2021
@chrisbonifacio chrisbonifacio moved this from Pending Triage to Investigating in Issues Triaging Aug 31, 2021
@chrisbonifacio
Copy link
Contributor

chrisbonifacio commented Sep 10, 2021

Hi @geeshans 👋 thanks for opening this issue! Sorry for the delayed response. I've been having trouble creating a developer account at FB, for some reason I'm not receiving the sms verification code they send. But, I may still be able to help. Can you check if the attributes from facebook are mapped to the user pool attributes similar to the settings below?

You can find these in the Cognito console -> User Pools -> select a user pool -> Federation/attribute mapping

Screen Shot 2021-09-10 at 1 17 28 PM

@chrisbonifacio chrisbonifacio added pending-response Issue is pending response from the issue requestor and removed investigating This issue is being investigated labels Sep 10, 2021
@chrisbonifacio chrisbonifacio moved this from Investigating to Can't Reproduce / Pending Response in Issues Triaging Sep 10, 2021
@chrisbonifacio chrisbonifacio added OAuth For issues related to OAuth Auth Related to Auth components/category and removed Auth Related to Auth components/category labels Sep 10, 2021
@geeshans
Copy link
Author

Hi @chrisbonifacio, thanks for looking into this. These are the attribute mappings for Facebook.
image

In the screenshot you share the mappings seem to be for Google so my screenshot does not have a "sub" attribute. But not sure if attribute mapping stage is reached at all since I'm checking the values returned from Facebook at "pre-signup" trigger.

@chrisbonifacio
Copy link
Contributor

chrisbonifacio commented Sep 13, 2021

@geeshans I was able to get the email from the pre-signup trigger like so:

exports.handler = async (event) => {
  console.log({
    email: event.request.userAttributes.email,
    event,
  });
};

From Cloudwatch logs

2021-09-13T22:30:19.966Z	e124f4fc-9fe4-4aea-bb7e-331392634314	INFO	{
  email: 'christopher.bonifacio@gmail.com',
  event: {
    version: '1',
    region: 'us-east-1',
    userPoolId: 'us-east-1_xxxxxxx',
    userName: 'facebook_10216096645289512',
    callerContext: {
      awsSdkVersion: 'aws-sdk-unknown-unknown',
      clientId: 'xxxxxxxxxxxxx'
    },
    triggerSource: 'PreSignUp_ExternalProvider',
    request: { userAttributes: [Object], validationData: {} },
    response: {
      autoConfirmUser: false,
      autoVerifyEmail: false,
      autoVerifyPhone: false
    }
  },
}

@geeshans
Copy link
Author

Hi @chrisbonifacio,

This is the output I get with the same pre-signup trigger.

2021-09-14T11:13:30.019Z	ba743176-2184-4cb8-961b-12344555	INFO	{
  email: undefined,
  event: {
    version: '1',
    region: 'eu-west-1',
    userPoolId: 'eu-west-x_xxxxxxxx',
    userName: 'Facebook_xxxxxxx',
    callerContext: {
      awsSdkVersion: 'aws-sdk-unknown-unknown',
      clientId: 'xxxxxxxxxxxxxxxx'
    },
    triggerSource: 'PreSignUp_ExternalProvider',
    request: { userAttributes: [Object], validationData: {} },
    response: {
      autoConfirmUser: false,
      autoVerifyEmail: false,
      autoVerifyPhone: false
    }
  }
}

Will you be able to share the configurations for your userpool?
aws cognito-idp describe-user-pool --user-pool-id us-west-2_xxxxxx

@chrisbonifacio
Copy link
Contributor

chrisbonifacio commented Sep 14, 2021

@geeshans Sure, here's my user pool config. You may also want to check for any differences between our OAuth config so I shared my aws-exports file as well.

{
    "UserPool": {
        "Id": "us-east-1_xxxxxxxx",
        "Name": "xxxxxxxxxxxx_userpool_xxxxxxxx-dev",
        "Policies": {
            "PasswordPolicy": {
                "MinimumLength": 8,
                "RequireUppercase": false,
                "RequireLowercase": false,
                "RequireNumbers": false,
                "RequireSymbols": false,
                "TemporaryPasswordValidityDays": 7
            }
        },
        "LambdaConfig": {
            "PreSignUp": "arn:aws:lambda:us-east-1:xxxxxxxx:function:xxxxxxXXXXXXPreSignup-dev"
        },
        "LastModifiedDate": "2021-09-13T17:05:05.535000-04:00",
        "CreationDate": "2021-08-20T14:24:25.080000-04:00",
        "SchemaAttributes": [
            {
                "Name": "sub",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": false,
                "Required": true,
                "StringAttributeConstraints": {
                    "MinLength": "1",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "given_name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "family_name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "middle_name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "nickname",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "preferred_username",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "profile",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "picture",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "website",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "email",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": true,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "email_verified",
                "AttributeDataType": "Boolean",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false
            },
            {
                "Name": "gender",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "birthdate",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "10",
                    "MaxLength": "10"
                }
            },
            {
                "Name": "zoneinfo",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "locale",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "phone_number",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "phone_number_verified",
                "AttributeDataType": "Boolean",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false
            },
            {
                "Name": "address",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "updated_at",
                "AttributeDataType": "Number",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "NumberAttributeConstraints": {
                    "MinValue": "0"
                }
            },
            {
                "Name": "identities",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {}
            }
        ],
        "AliasAttributes": [
            "email"
        ],
        "VerificationMessageTemplate": {
            "DefaultEmailOption": "CONFIRM_WITH_CODE"
        },
        "MfaConfiguration": "OFF",
        "EstimatedNumberOfUsers": 2,
        "EmailConfiguration": {
            "EmailSendingAccount": "COGNITO_DEFAULT"
        },
        "SmsConfiguration": {
            "SnsCallerArn": "arn:aws:iam::xxxxxxxx:role/snsxxxxxxxx-dev",
            "ExternalId": "xxxxxxxx_role_external_id"
        },
        "UserPoolTags": {},
        "Domain": "xxxxxxxx-dev",
        "AdminCreateUserConfig": {
            "AllowAdminCreateUserOnly": false,
            "UnusedAccountValidityDays": 7
        },
        "UsernameConfiguration": {
            "CaseSensitive": false
        },
        "Arn": "arn:aws:cognito-idp:us-east-1:xxxxxxxx:userpool/us-east-1_xxxxxxxx"
    }
}

aws-exports file

const awsmobile = {
    "aws_project_region": "us-east-1",
    "aws_cognito_identity_pool_id": "us-east-1:xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx",
    "aws_cognito_region": "us-east-1",
    "aws_user_pools_id": "us-east-1_xxxxxxxx",
    "aws_user_pools_web_client_id": "xxxxxxxxxxxx",
    "oauth": {
        "domain": "xxxxxx-dev.auth.us-east-1.amazoncognito.com",
        "scope": [
            "phone",
            "email",
            "openid",
            "profile",
            "aws.cognito.signin.user.admin"
        ],
        "redirectSignIn": "http://localhost:3000/",
        "redirectSignOut": "http://localhost:3000/",
        "responseType": "code"
    },
    "federationTarget": "COGNITO_USER_AND_IDENTITY_POOLS",
    "aws_cognito_login_mechanisms": [
        "EMAIL",
        "FACEBOOK",
        "GOOGLE"
    ],
    "aws_cognito_signup_attributes": [
        "EMAIL"
    ],
    "aws_cognito_mfa_configuration": "OFF",
    "aws_cognito_mfa_types": [
        "SMS"
    ],
    "aws_cognito_password_protection_settings": {
        "passwordPolicyMinLength": 8,
        "passwordPolicyCharacters": []
    },
};

@chrisbonifacio
Copy link
Contributor

chrisbonifacio commented Sep 16, 2021

@geeshans just out of curiosity, could you try creating a custom button that calls Auth.federatedSignIn({ provider: "Facebook" }) instead of using the <amplify-facebook-button>? I think the amplify button is authenticating against the Identity Pool rather than the User Pool, which should map the attributes for you.

this is React syntax but you can use the Angular equivalent of this:

<button onClick={() => Auth.federatedSignIn({ provider: "Facebook" })}>
  Sign In with Facebook
</button>

@geeshans
Copy link
Author

Thanks @chrisbonifacio, creating a custom button worked!

Is this the expected behaviour or a bug?

For anyone who want the Angular equivalent:

        <button  slot="federated-buttons" (click)=customSignIn()>Facebook</button>
  customSignIn(): void{
    Auth.federatedSignIn({provider: CognitoHostedUIIdentityProvider.Facebook });
  }

@chrisbonifacio
Copy link
Contributor

@geeshans This is expected behavior. There are different auth workflows depending on the argument passed to Auth.federatedSignIn. One authenticates against the User Pool where attributes can be mapped, the other uses the Identity Pool.

User Pool workflow

Auth.federatedSignIn({provider: CognitoHostedUIIdentityProvider.Facebook });

Identity Pool workflow

const {
    token, // the token you get from the provider
    domainOrProviderName, // Either the domain of the provider(e.g. accounts.your-openid-provider.com) or the provider name, for now the library only supports 'google', 'facebook', 'amazon', 'developer'
    expiresIn, // the time in ms which describes how long the token could live
    user,  // the user object you defined, e.g. { username, email, phone_number }
    identity_id // Optional, the identity id specified by the provider
} = getFromProvider(); // arbitrary function

Auth.federatedSignIn(
    domain,
    {
        token,
        identity_id, // Optional
        expires_at: expiresIn * 1000 + new Date().getTime() // the expiration timestamp
    },
    user
).then(cred => {
    // If success, you will get the AWS credentials
    console.log(cred);
    return Auth.currentAuthenticatedUser();
}).then(user => {
    // If success, the user object you passed in Auth.federatedSignIn
    console.log(user);
}).catch(e => {
    console.log(e)
});

the amplify-facebook-button seems to use the Identity Pool workflow.

Issues Triaging automation moved this from Can't Reproduce / Pending Response to Triaged/Closed By DSE Sep 22, 2021
@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Auth Related to Auth components/category OAuth For issues related to OAuth pending-response Issue is pending response from the issue requestor
Projects
No open projects
Issues Triaging
Triaged/Closed By DSE
Development

No branches or pull requests

3 participants