Skip to content

Amplify Does Not Use Endpoint for Cognito Auth Calls #5784

Open
@mozakassab

Description

@mozakassab

Description

When configuring Amplify in a Flutter application with existing resources and specifying an Endpoint for CognitoUserPool, the SDK does not route Cognito calls through the provided endpoint. This behavior is unexpected, and was working before with v1.
Here's an example of the configuration passed for existing resources:

String amplifyconfig = ''' {
  "UserAgent": "aws-amplify-cli/2.0",
  "Version": "1.0",
  "auth": {
    "plugins": {
      "awsCognitoAuthPlugin": {
        "IdentityManager": {
          "Default": {}
        },
        "CognitoUserPool": {
          "Default": {
            "PoolId": "${EnvVariables.cognitoUserPoolID.value}",
            "AppClientId": "${EnvVariables.cognitoAppClientID.value}",
            "Region": "${EnvVariables.awsRegion.value}",
            "Endpoint": "${EnvVariables.awsCognitoEndpoint.value}"
          }
        },
        "Auth": {
          "Default": {
            "authenticationFlowType": "CUSTOM_AUTH"
          }
        }
      }
    }
  }
}''';

Categories

  • Analytics
  • API (REST)
  • API (GraphQL)
  • Auth
  • Authenticator
  • DataStore
  • Notifications (Push)
  • Storage

Steps to Reproduce

  1. Configure Amplify with existing resources, and specify an endpoint for CognitoUserPool:
String amplifyconfig = ''' {
  "UserAgent": "aws-amplify-cli/2.0",
  "Version": "1.0",
  "auth": {
    "plugins": {
      "awsCognitoAuthPlugin": {
        "IdentityManager": {
          "Default": {}
        },
        "CognitoUserPool": {
          "Default": {
            "PoolId": "${EnvVariables.cognitoUserPoolID.value}",
            "AppClientId": "${EnvVariables.cognitoAppClientID.value}",
            "Region": "${EnvVariables.awsRegion.value}",
            "Endpoint": "${EnvVariables.awsCognitoEndpoint.value}"
          }
        },
        "Auth": {
          "Default": {
            "authenticationFlowType": "CUSTOM_AUTH"
          }
        }
      }
    }
  }
}''';
  1. Add Cognito Auth plugin:
Amplify.addPlugin(
        AmplifyAuthCognito(),
      );
  1. Configure Amplify:
Amplify.configure(amplifyconfig);
  1. Try calling any Cognito method and check the network logs (Request is not made through the specified Endpoint):
Amplify.Auth.getPlugin(AmplifyAuthCognito.pluginKey).signUp(
        username: username,
        password: password
        );

Screenshots

No response

Platforms

  • iOS
  • Android
  • Web
  • macOS
  • Windows
  • Linux

Flutter Version

3.27.1

Amplify Flutter Version

2.5.0

Deployment Method

Custom Pipeline

Schema

No response

Metadata

Metadata

Labels

authIssues related to the Auth CategorybugSomething is not working; the issue has reproducible steps and has been reproduced

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions