76484
76484

Reputation: 8993

How to get Google OAuth 2.0 Client to pass client_id to AWS Cognito User Pool domain with Google Social Identity Provider

I am getting an error when trying to sign-in to my single-page application (SPA) using the signInWithRedirect export of the aws-amplify/auth node package and using Google as a Social Identity Provider.

For my setup, I have done the following:

import { Amplify } from 'aws-amplify'
import { signInWithRedirect } from 'aws-amplify/auth'

Amplify.configure({
  Auth: {
    Cognito: {
      loginWith: {
        oauth: {
          domain: '{MY_COGNITO_DOMAIN}',
          redirectSignIn: ['http://localhost:5173/'],
          responseType: 'code',
          scopes: ['email', 'openid']
        }
      },
      userPoolClientId: '{MY_USER_POOL_CLIENT_ID}',
      userPoolId: '{MY_USER_POOL_ID}'
    }  
  }
});

const signInWithGoogle = () => {
  signInWithRedirect({
    provider: 'Google'
  })
}

When the signInWithGoogle method is invoked in web application, the browser's network tab shows the following requests:

The Cognito error page that is the terminus of this flow displays the following message:

Missing required parameters
Missing required parameter client_id in request URL.

This is where I am stuck. As far as I understand, Cognito and Google do all the magic of constructing these redirect URLs and, presumably, each should be providing in the request parameters all of the data that the other requires. I don't know what I can change, or where, to get this client_id passed from Google to Cognito.

Upvotes: 1

Views: 187

Answers (0)

Related Questions