AWS Amplify Invalid Grant

Viewed 1542

I am using Angular 9 for the front end of my application. I am using AWS Amplify for user authentication. I am trying to intergrate google sign up with my application. I am able to log the user in with google but I seem to be getting an invalid grant error when the user is redirected after sign in.

POST **domain_name** 400

ConsoleLogger.js:107 [ERROR] 54:09.165 OAuth - Error handling auth response. Error: invalid_grant
at OAuth.<anonymous> (OAuth.js:186)
at step (OAuth.js:56)
at Object.next (OAuth.js:37)
at fulfilled (OAuth.js:28)
at ZoneDelegate.invoke (zone-evergreen.js:364)
at Zone.run (zone-evergreen.js:123)
at zone-evergreen.js:857
at ZoneDelegate.invokeTask (zone-evergreen.js:399)
at Zone.runTask (zone-evergreen.js:167)
at drainMicroTaskQueue (zone-evergreen.js:569)

I am using Auth.federatedSignIn method to in my front end to call the API. Here is the relevant component code in auth.component.ts

  import { Component, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core';
  import { Amplify } from "aws-amplify";
  import Auth, { CognitoHostedUIIdentityProvider } from "@aws-amplify/auth";
  import { onAuthUIStateChange, CognitoUserInterface, AuthState, FormFieldTypes } from '@aws-amplify/ui-components';

async signInWithGoogle() {
console.log("signInWithGoogle called");
try {
  Auth.federatedSignIn({'provider': CognitoHostedUIIdentityProvider.Google}).then(
    cred => {
      this.authState = AuthState.SignedIn;
      console.log(cred);
    }
  ).catch(
    e => {
      // console.log(e);

    }
  );
} catch (error) {
  console.log("Error Calling signInWithGoogle");

}

}

Then I have a button which calls signInWithGoogle() on click. Upon the using choosing their google account, the aforementioned error is called. Also, I am only calling Amplify.configure(awsconfig); once in my app.module.ts file.

0 Answers
Related