Skip to content
← Back to activity

Immutable solution version

Feature request OAuth2

Version 2Sign in to save

Complete solution

Shows how to fix feature request OAuth2. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Check your version of Amazon Cognito first , maintainers often fix the underlying bug in a later release, and the thread may predate it. Issue aws-samples/amazon-cognito-passwordless-auth#76 (closed, 7 comments): Would it be possible to add hooks to support OAuth2 for federated authentication from social / enterprise IdPs?

When to use

You are seeing this: I'm willing to help implement if needed, but I wanted to open this issue before doing any work on it to start a discussion to see if it's inline with the goals of this library. Use this skill when you run into "Feature request OAuth2".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

What happened

Issue aws-samples/amazon-cognito-passwordless-auth#76 (closed, 7 comments): Would it be possible to add hooks to support OAuth2 for federated authentication from social / enterprise IdPs? I'm willing to help implement if needed, but I wanted to open this issue before doing any work on it to start a discussion to see if it's inline with the goals of this library. The idea would be to start by updating the configure method and maybe add something like ```typeScript Passwordless.configure({ //...

What works

When you federate a Cognito user pool with social or enterprise IdPs, Cognito auto-creates a federated user on first login, which duplicates your native user. To keep one user per person: use the pre-sign-up Lambda trigger to look up an existing native user with the same email when a federated user signs up. If one exists, link the federated identity to that existing Cognito user and return undefined from the trigger so no duplicate gets created. Also keep the split straight: native users (Cognito stores the password) vs federated users (their attributes get overwritten from the IdP on every federated login), and once you federate, sign-up handling moves to the IdP.

Caveats

This comes from one real issue thread (https://github.com/aws-samples/amazon-cognito-passwordless-auth/issues/76); it is the verified fix or approach from that thread, not a general manual. Check your version of Amazon Cognito first , maintainers often fix the underlying bug in a later release, and the thread may predate it.

Evidence

Issue gh:aws-samples/amazon-cognito-passwordless-auth#76 asked: Issue aws-samples/amazon-cognito-passwordless-auth#76 (closed, 7 comments): Would it be possible to add hooks to support OAuth2 for federated authentication from social / enterprise IdPs? I'm willing to help implement if needed, but I wanted to open this issue before doing any work on it to start a discussion to see if it's inline with the goals of this library. The idea would be to start by updating the configure method and maybe add something like ```typeScript Passwordless.configure({ //... The verified answer from the thread: When you federate a Cognito user pool with social or enterprise IdPs, Cognito auto-creates a federated user on first login, which duplicates your native user. To keep one user per person: use the pre-sign-up Lambda trigger to look up an existing native user with the same email when a federated user signs up. If one exists, link the federated identity to that existing Cognito user and return undefined from the trigger so no duplicate gets created. Also keep the split straight: native users (Cognito stores the password) vs federated users (their attributes get overwritten from the IdP on every federated login), and once you federate, sign-up handling moves to the IdP. Source: https://github.com/aws-samples/amazon-cognito-passwordless-auth/issues/76

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_zVIECneoFf8ksOfTwLWakw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Feature request OAuth2 <span>— Vectle</span></a>