Skip to content

Amplify.configure() throws error when using Identity Pool only (no User Pool) — v6 #14315

@jacoyutorius

Description

@jacoyutorius

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

Authentication

Amplify Version

v6

Amplify Categories

auth

Backend

None

Environment information

  System:
    OS: macOS 15.3.1
    CPU: (10) arm64 Apple M4
    Memory: 82.48 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 23.9.0 - /opt/homebrew/bin/node
    npm: 10.9.2 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 134.0.6998.119
    Safari: 18.3
  npmPackages:
    @aws-amplify/auth: ^6.11.6 => 6.11.6
    @aws-amplify/auth/cognito:  undefined ()
    @aws-amplify/auth/cognito/server:  undefined ()
    @aws-amplify/auth/enable-oauth-listener:  undefined ()
    @aws-amplify/auth/server:  undefined ()
    aws-amplify: ^6.13.6 => 6.13.6
    aws-amplify/adapter-core:  undefined ()
    aws-amplify/adapter-core/internals:  undefined ()
    aws-amplify/analytics:  undefined ()
    aws-amplify/analytics/kinesis:  undefined ()
    aws-amplify/analytics/kinesis-firehose:  undefined ()
    aws-amplify/analytics/personalize:  undefined ()
    aws-amplify/analytics/pinpoint:  undefined ()
    aws-amplify/api:  undefined ()
    aws-amplify/api/internals:  undefined ()
    aws-amplify/api/server:  undefined ()
    aws-amplify/auth:  undefined ()
    aws-amplify/auth/cognito:  undefined ()
    aws-amplify/auth/cognito/server:  undefined ()
    aws-amplify/auth/enable-oauth-listener:  undefined ()
    aws-amplify/auth/server:  undefined ()
    aws-amplify/data:  undefined ()
    aws-amplify/data/server:  undefined ()
    aws-amplify/datastore:  undefined ()
    aws-amplify/in-app-messaging:  undefined ()
    aws-amplify/in-app-messaging/pinpoint:  undefined ()
    aws-amplify/push-notifications:  undefined ()
    aws-amplify/push-notifications/pinpoint:  undefined ()
    aws-amplify/storage:  undefined ()
    aws-amplify/storage/s3:  undefined ()
    aws-amplify/storage/s3/server:  undefined ()
    aws-amplify/storage/server:  undefined ()
    aws-amplify/utils:  undefined ()
  npmGlobalPackages:
    corepack: 0.31.0
    npm: 10.9.2

Describe the bug

Describe the bug

When using Amplify v6 with Identity Pool only (no User Pool), calling Amplify.configure() throws a runtime error.

To Reproduce

  1. Create a Cognito Identity Pool with unauthenticated access enabled.
  2. Set proper permissions on the unauthenticated IAM role (GetId, GetCredentialsForIdentity)
  3. Create a minimal JavaScript file like this:
import { Amplify } from 'aws-amplify';
import { fetchAuthSession } from 'aws-amplify/auth';

async function test() {
  try {
    Amplify.configure({
      Auth: {
        identityPoolId: 'ap-northeast-1:xxxxxxx',
        region: 'ap-northeast-1',
        mandatorySignIn: false,
      }
    });

    const session = await fetchAuthSession();
    const credentials = await Promise.resolve(session.credentials);

    console.log('identityId:', session.identityId);
    console.log('credentials:', credentials);
  } catch (err) {
    console.error('Error during fetchAuthSession():', err);
  }
}

test();
{
  "name": "amplify-v6-auth-no-userpool-issue",
  "version": "1.0.0",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "description": "",
  "dependencies": {
    "@aws-amplify/auth": "^6.11.6",
    "aws-amplify": "^6.13.6"
  }
}

and this code outputs this,

Error during fetchAuthSession(): TypeError: Cannot read properties of undefined (reading 'loginWith')
    at AmplifyClass.notifyOAuthListener (file:///Users/yuto/work/node/amplify-v6-auth-no-userpool-issue/node_modules/@aws-amplify/core/dist/esm/singleton/Amplify.mjs:78:48)
    at AmplifyClass.configure (file:///Users/yuto/work/node/amplify-v6-auth-no-userpool-issue/node_modules/@aws-amplify/core/dist/esm/singleton/Amplify.mjs:56:14)
    at Object.configure (file:///Users/yuto/work/node/amplify-v6-auth-no-userpool-issue/node_modules/aws-amplify/dist/esm/initSingleton.mjs:42:21)
    at test (file:///Users/yuto/work/node/amplify-v6-auth-no-userpool-issue/issue.js:6:13)
    at file:///Users/yuto/work/node/amplify-v6-auth-no-userpool-issue/issue.js:24:1
    at ModuleJob.run (node:internal/modules/esm/module_job:273:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:600:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:98:5)

Expected behavior

I expects fetchAuthSession() return valid temporary credentials when using an Identity Pool-only configuration, just like the AWS SDK does.

Reproduction steps

Code Snippet

The same Identity Pool configuration works with the AWS SDK directly:

import {
  CognitoIdentityClient,
  GetIdCommand,
  GetCredentialsForIdentityCommand
} from '@aws-sdk/client-cognito-identity';

const client = new CognitoIdentityClient({ region: 'ap-northeast-1' });

const identityId = (
  await client.send(new GetIdCommand({ IdentityPoolId: '...' }))
).IdentityId;

const credentials = (
  await client.send(new GetCredentialsForIdentityCommand({ IdentityId: identityId }))
).Credentials;

Log output

// Put your logs below this line


aws-exports.js

Amplify.configure({
  Auth: {
    identityPoolId: 'ap-northeast-1:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
    region: 'ap-northeast-1',
    mandatorySignIn: false
  }
});

Manual configuration

No response

Additional configuration

aws cognito-identity describe-identity-pool --identity-pool-id ap-northeast-1:xxxxxxxxx
{
    "IdentityPoolId": "ap-northeast-1:xxxxxxxxx",
    "IdentityPoolName": "MyIdentityPool",
    "AllowUnauthenticatedIdentities": true,
    "AllowClassicFlow": false,
    "IdentityPoolTags": {}
}

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    AuthRelated to Auth components/categoryfeature-requestRequest a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions