aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.42k stars 2.12k forks source link

Cannot get first & lastname user attributes via cognito SignInWithApple #9752

Closed tamerkalieh closed 2 years ago

tamerkalieh commented 2 years ago

Before opening, please confirm:

JavaScript Framework

Vue

Amplify APIs

Authentication

Amplify Categories

auth

Environment information

``` System: OS: macOS 11.6 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 1.26 GB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 14.16.1 - /usr/local/bin/node Yarn: 1.22.15 - /usr/local/bin/yarn npm: 6.14.12 - /usr/local/bin/npm Browsers: Chrome: 96.0.4664.45 Edge: 99.0.1150.55 Firefox: 94.0.1 Safari: 15.0 npmPackages: @babel/preset-env: 7.16.5 => 7.16.5 @babel/runtime: 7.16.3 => 7.16.3 @checkout-charlie/bi-sparwelt-tracking: 7.0.1 => 7.0.1 @fortawesome/fontawesome-svg-core: 1.2.32 => 1.2.32 @fortawesome/free-brands-svg-icons: 5.15.1 => 5.15.1 @fortawesome/pro-light-svg-icons: 5.15.1 => 5.15.1 @fortawesome/pro-solid-svg-icons: 5.15.1 => 5.15.1 @fortawesome/vue-fontawesome: 2 => 2.0.2 @nestjsx/crud-request: 5.0.0-alpha.3 => 5.0.0-alpha.3 @nuxtjs/dotenv: 1.4.1 => 1.4.1 @nuxtjs/eslint-config: 6.0.1 => 6.0.1 @nuxtjs/eslint-module: ^2.0.0 => 2.0.0 @nuxtjs/pwa: 3.3.5 => 3.3.5 @nuxtjs/robots: 2.5.0 => 2.5.0 @nuxtjs/sitemap: 2.4.0 => 2.4.0 @nuxtjs/storybook: 4.2.0 => 4.2.0 @nuxtjs/stylelint-module: 4.0.0 => 4.0.0 @nuxtjs/tailwindcss: 4.2.1 => 4.2.1 @storybook/addon-a11y: 6.3.12 => 6.3.12 @tailwindcss/typography: 0.4.1 => 0.4.1 aws-amplify: 4.3.8 => 4.3.8 babel-eslint: 10.1.0 => 10.1.0 babel-jest: 27.4.2 => 27.4.2 body-parser: 1.19.1 => 1.19.1 (1.19.0) chromatic: 6.1.0 => 6.1.0 class-validator: 0.13.2 => 0.13.2 core-js: 3.19.1 => 3.19.1 (2.6.12) cypress: 9.2.1 => 9.2.1 eslint: 7.32.0 => 7.32.0 eslint-config-prettier: 8.3.0 => 8.3.0 eslint-plugin-cypress: 2.12.1 => 2.12.1 eslint-plugin-nuxt: 2.0.0 => 2.0.0 eslint-plugin-prettier: 4.0.0 => 4.0.0 fibers: 5.0.0 => 5.0.0 husky: 7.0.4 => 7.0.4 jest: 27.4.3 => 27.4.3 lint-staged: 11.2.6 => 11.2.6 lodash: 4.17.21 => 4.17.21 md.js: 0.2.6 => 0.2.6 nuxt: 2.15.8 => 2.15.8 nuxt-basic-auth-module: 1.4.0 => 1.4.0 nuxt-i18n: 6.28.1 => 6.28.1 pm2: 5.1.2 => 5.1.2 pm2-plus-custom-metrics: 1.0.0 postcss: 8.3.11 => 8.3.11 (7.0.36) prettier: 2.2.1 => 2.2.1 (1.19.1) python-app: 1.0.0 sass: 1.44.0 => 1.44.0 sass-loader: 10.1.1 => 10.1.1 shrink-ray-current: 4.1.3 => 4.1.3 simple-http-server: 1.0.0 stylelint: 13.13.1 => 13.13.1 ufo: 0.7.9 => 0.7.9 unfetch: 4.2.0 => 4.2.0 unfetch-polyfill: undefined () vue-cli-webpack: 1.0.0 vue-lazy-hydration: 2.0.0-beta.4 => 2.0.0-beta.4 npmGlobalPackages: corepack: 0.10.0 n: 7.5.0 npm: 6.14.12 yarn: 1.22.15 ```

Describe the bug

I am currently trying to implement SignInWithApple in my website. The authentication works and I can log in, get the logged in user and can log the user out. But in the object of the user session I don't get the first_name & last_name information.

Expected behavior

Retrieve the first & last name of the signed in user

Reproduction steps

  1. I'm testing directly on the AWS UI & on my website. For my website I pulled "aws-amplify": "4.3.8"
  2. Connected my page to amplify manually with the configuration I pasted in "Manual configuration".
  3. Initialized the apple login
  4. After successful login I get redirected back to my page with an authenticated user

Code Snippet

import { Auth } from 'aws-amplify'

export default {
  methods: {
    signInWithApple() {
      Auth.federatedSignIn({ provider: 'SignInWithApple' })
    }
  }
}

Getting the user authenticated user with:

const authUser = await Auth.currentAuthenticatedUser()
console.log(authUser)

Log output

If I console.log the current authenticated user, I get a bunch of data but where I expect the first & last name to be, I get the user email and some other data.

``` attributes: email: "xxxx@gmail.com" email_verified: false identities: "[{\"userId\":\"XXXX\",\"providerName\":\"SignInWithApple\",\"providerType\":\"SignInWithApple\",\"issuer\":null,\"primary\":true,\"dateCreated\":1648472621118}]" sub: "xxxxxxxx" ``` ``` preferredMFA: "NOMFA" signInUserSession: CognitoUserSession accessToken: CognitoAccessToken jwtToken: "..." payload: auth_time: 1648643902 client_id: "xxx" cognito:groups: ['eu-central-1_XXX_SignInWithApple'] exp: 1648730302 iat: 1648643902 iss: "https://cognito-idp.eu-central-1.amazonaws.com/eu-central-1_XXXX" jti: "XXXX" origin_jti: "XXXX" scope: "aws.cognito.signin.user.admin phone openid profile email" sub: "XXXXX" token_use: "access" username: "signinwithapple_XXXXX" version: 2 ```

aws-exports.js

No response

Manual configuration

Amplify.configure({
    Auth: {
      region: 'eu-central-1',
      userPoolId: 'eu-central-1_XXXXXXXX',
      userPoolWebClientId: 'XXXXXXXXXXXXXX',
      mandatorySignIn: false,
      oauth: {
        domain: `xxxxxxxxxx.auth.eu-central-1.amazoncognito.com`,
        scope: [
          'profile',
          'phone',
          'openid',
          'email',
          'aws.cognito.signin.user.admin'
        ],
        redirectSignIn: `http://localhost:3000/de`,
        redirectSignOut: `http://localhost:3000/de`,
        responseType: 'code'
      }
    }
  })

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

Bildschirmfoto 2022-03-30 um 14 26 54 Bildschirmfoto 2022-03-30 um 14 27 47 Bildschirmfoto 2022-03-30 um 14 49 06
simlevesque commented 2 years ago

@tamerkalieh did you manage to fix this issue ? it still prevents us from updating to this day.

chrisbonifacio commented 2 years ago

@tamerkalieh did you sign up for your app with the user before mapping the attributes? You may have to delete the app from the user's Apple ID and then sign up again as Apple only allows access to user information on the first sign in.

Possibly related to, or duplicate of, this issue: https://github.com/aws-amplify/amplify-js/issues/8976

github-actions[bot] commented 1 year ago

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 amplify-help forum.