#✅ - Auth fails after redirect

7 messages · Page 1 of 1 (latest)

indigo panther
#

I have a project where users are authenticated and signed in via Cognito using the amplify Auth module. I also need those users to be able to provide me with authorization for some actions from their Google accounts. I'm using Googles OAuth2 client from their googleapis module.

Once authorized via Googles auth URL, the user gets redirected back to a page on my webapp. However, seems like Auth.currentAuthenticatedUser() shows as not authenticated anymore, so I'm unable to call the APIs I need at that point.

In the console, I see a warning message that some cookies are misusing the same-site property. I suspect that this has something to do with the issue.

Any help would really be appreciated. Thanks

indigo panther
#

In case anyone runs into this problem in the future, here's how I fixed it:

Amplify.configure({
  ...awsExports,
  ssr: true,
  cookieStorage: {
    // - Cookie domain (only required if cookieStorage is provided)
    domain: "localhost",
    // (optional) - Cookie path
    path: "/",
    sameSite: "lax",
  },
});
cloud tendon
#

Glad you were able to get this resolved @indigo panther 😄

valid gustBOT
#

✅ - Auth fails after redirect

#

Answer selected!


Amplify.configure({
...awsExports,
ssr: true,
cookieStorage: {
// - Cookie domain (only required if cookieStorage is provided)
domain: "localhost",
// (optional) - Cookie path
path: "/",
sameSite: "lax",
},
});

Kudos to @indigo panther!
#1148557354338623539 message
neon pilot
#

@indigo panther I am working on something that sounds somewhat similar to this but am having an issue where the redirect from the OAuth consent screen gets picked up by the Amplify authenticator, did you run into a similar issue and if so were you able to work around this?

indigo panther
#

Hey, I actually stopped working with Amplify a while back so I can't remember. I don't remember this issue though. Sorry :/