0

I'm getting an OAuthNotConfigureException: oauth param not configured error when trying to use Google OAuth with AWS Amplify v6, even though my configuration appears correct.

Environment:

  • AWS Amplify v6.15.1
  • Next.js 14.2.30
  • AWS Cognito User Pool with Google Identity Provider
  • Google OAuth 2.0 credentials configured

Current Configuration:

// src/config/amplify.ts
import { Amplify } from 'aws-amplify';

const amplifyConfig = {
  Auth: {
    Cognito: {
      userPoolId: "userPoolId",
      userPoolClientId: "userPoolClientId",
      signUpVerificationMethod: "code",
      loginWith: {
        email: true,
        phone: false,
        username: false
      },
      userAttributes: {
        email: { required: true },
        name: { required: true }
      },
      socialProviders: {
        google: {
          clientId: "clientId"
        }
      }
    }
  },
  oauth: {
    domain: "domain",
    scope: ["email", "openid", "profile"],
    redirectSignIn: "http://localhost:3000/signin",
    redirectSignOut: "http://localhost:3000/",
    responseType: "code",
    providers: ["Google"]
  }
};

Amplify.configure(amplifyConfig);

Error Details:

OAuthNotConfigureException: oauth param not configured.
at assertOAuthConfig (webpack-internal:///./node_modules/@aws-amplify/core/dist/esm/singleton/Auth/utils/index.mjs:33:62)
at signInWithRedirect (webpack-internal:///./node_modules/@aws-amplify/auth/dist/esm/providers/cognito/apis/signInWithRedirect.mjs:53:89)

Code that triggers the error:

// src/contexts/AuthContext.tsx
const signInWithGoogle = async () => {
  try {
    await signInWithRedirect({ provider: 'Google' });
  } catch (error) {
    console.error('Google sign in error:', error);
    throw error;
  }
};

Debug Output: The configuration is being loaded correctly as shown in the console:

{
  "Auth": {
    "Cognito": {
      "userPoolId": "userPoolId",
      "userPoolClientId": "userPoolClientId",
      // ... rest of config
    }
  },
  "oauth": {
    "domain": "domain",
    // ... rest of oauth config
  }
}

What I've tried:

  • Moving OAuth config inside Auth.Cognito
  • Using different OAuth configuration formats
  • Verifying all environment variables

Additional Context:

  • The error occurs specifically when calling signInWithRedirect({ provider: 'Google' })
  • The configuration loads without errors during Amplify.configure()
  • This is a fresh setup with no previous Amplify configurations

Any help would be greatly appreciated! This seems like a configuration issue specific to Amplify v6's OAuth implementation., should I use v5?

1 Answer 1

0

Maybe something changed in the Amplify v6's OAuth. I met the same problem with Cognito Hosted UI. I followed the stack trace and figured out that the assertOAuthConfig function (a validator used by signInWithRedirect ) requires oauth property present at Auth.Cognito.loginWith). So I manually edited the configuration object to bypass the validator and the signInWithRedirect worked correctly.

The working code (you need to update something to work with the Google provider):

Amplify.configure({
    Auth: {
        Cognito: {
            userPoolClientId: '4h8XXXXXX86qt',
            userPoolId: 'ap-southeast-1_XXXXXXX',

            loginWith: {
                oauth: {
                    domain: 'xxxxx.auth.ap-southeast-1.amazoncognito.com',
                    scopes: ['email', 'openid', 'profile'],
                    redirectSignIn: ['http://localhost:3000/login'],
                    redirectSignOut: ['http://localhost:3000/'],
                    responseType: 'code',
                },
            },
        },
    },
})

// some handler:
await auth.signInWithRedirect() // Note: if you do not pass an argument to signInWithRedirect it will redirect your users to the Cognito Hosted UI

NOTE:

  • I'm a newbie to Amplify and I just want to use 'aws-amplify/auth' to test some Cognito features so I don't know if the configuration model was changed by AWS or not.

  • Changing the configuration manually may cause others problems => double-check with official documents.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.