#✅ - Cognito User Pools Authentication Error with Amplify + Auth0 Integration

5 messages · Page 1 of 1 (latest)

raven forum
#

When following this AWS tutorial for Next.js + Auth0 integration (https://aws.amazon.com/blogs/mobile/how-to-build-next-js-apps-with-authentication-using-aws-amplify-and-auth0/), the npx ampx sandbox command fails due to a mismatch between the data schema authorization and auth configuration.

Failed to instantiate data construct
Caused By: @auth directive with 'userPools' provider found, but the project has no Cognito User Pools authentication provider configured.

The approach in the article seems very different from what is laid out in the docs: https://docs.amplify.aws/react/build-a-backend/auth/advanced-workflows/

Can anyone tell if the integration outlined in this article (https://aws.amazon.com/blogs/mobile/how-to-build-next-js-apps-with-authentication-using-aws-amplify-and-auth0/) is valid?

#

The article defined the auth resource as:

export const auth = defineAuth({
  loginWith: {
    email: {
      verificationEmailSubject: 'Welcome to the Blog post app 👋 Verify your email!'
    },
    externalProviders: {
      oidc: [
        {
          name: 'Auth0',
          clientId: secret('AUTH0_CLIENT_ID'),
          clientSecret: secret('AUTH0_CLIENT_SECRET'),
          issuerUrl: process.env.ISSUER_URL || '',
          scopes: ['openid', 'profile', 'email']
        },
      ],
      callbackUrls: [process.env.CALLBACK_URL || ''],
      logoutUrls: [process.env.LOGOUT_URL || ''],
    },
  },
});

and the backend resource as:

import { type ClientSchema, a, defineData } from "@aws-amplify/backend";

const schema = a.schema({
  Todo: a
    .model({
      content: a.string(),
    })
    .authorization((allow) => [allow.authenticated()]),
});

export type Schema = ClientSchema<typeof schema>;

export const data = defineData({
  schema,
  authorizationModes: {
    defaultAuthorizationMode: 'userPool'
  },
});
median skiff
#

hey @raven forum , quickly tested this on a sandbox env but did not run into this error
the example should deploy without any error. Does the backend.ts have auth and data added to defineBackend?

raven forum
#

Yup, I overlooked the backend.ts file. Got passed my error. Things seem to be building. Thanks for being my second set of eyes!

pine sunBOT
#

✅ - Cognito User Pools Authentication Error with Amplify + Auth0 Integration