Skip to content

What should I pass to "Amplify.configure" when my cognito user pool is setup to use google authentication

0

I am using the libraries "aws-amplify/ui-react" and "aws-amplify" in my react app. by the way I am using amplify as a library with existing AWS resources only not creating and managing any aws resources through amplify.

I need to let the uses sign in using google. I have setup up everything on the cognito side in aws console and tested with the hosted UI and all works fine. However, when trying to use the below code I get the google button but when I click it I get the error "oauth param not configured." on the browser. I guess something is missing on the call to Amplify.configure({ but I can't find any docs or help on how to do this. Please can someone shed some light on this? I am really going crazy now! 😩

import "./App.css";
import { Authenticator } from "@aws-amplify/ui-react";
import { Amplify } from "aws-amplify";

Amplify.configure({
  Auth: {
    Cognito: {
      userPoolClientId: "<my client id>",
      userPoolId: "<my pool id>",
    },
  },
});

function App() {
  const [count, setCount] = useState(0);

  return (
    <Authenticator socialProviders={["google"]}>
      {({ signOut, user }) => (
        <main>
          <h1>Hello {user?.username}</h1>
          <button onClick={signOut}>Sign out</button>
        </main>
      )}
    </Authenticator>
  );
}

export default App;

asked a year ago277 views
1 Answer
2
Accepted Answer

In case this helps anyone I figured this out after digging into these docs https://aws-amplify.github.io/amplify-js/api/classes/aws_amplify.adapter_core._Reference_Types_.AmplifyClass.html#configure

By the way, I feel like talking to myself here. No answers amplify related questions? 🤔 am I the only one using amplify with existing aws resources this way? Is there a better place to ask questions about amplify?

Amplify.configure({
  Auth: {
    Cognito: {
      loginWith: {
        oauth: {
          domain: "<your domain here>.amazoncognito.com",
          providers: ["Google"],
          redirectSignIn: ["http://localhost:5173"],
          redirectSignOut: [],
          responseType: "code",
          scopes: ["openid", "email", "profile"],
        },
      },
      userPoolClientId: "<your user pool client id>",
      userPoolId: "your user pool id",
    },
  },
});
answered a year ago
EXPERT
reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.