'In AWS Cognito or Amplify Auth, can I create a user from a uid, without user interaction, similar to the Firebase Auth "custom token" approach?

I'm migrating a web app from firebase to Amplify. In firebase, you can silently sign-up / sign-in a user without any user interaction or password, as long as you somehow already have a unique identifier of the user. I wonder if Amplify has a equivalent flow. The process is something like this:

// backend:
function exchangeUidForToken(uid: string) {
  const jwt = await firebaseAdmin.auth.createCustomToken(uid);
  return jwt;
}

// frontend:
function authByUid(uid: string) {
  const jwt = await backendFunctions.exchangeUidForToken(uid);
  await firebase.auth.signInWithToken(jwt);
  // user is now signed in
}

So if you have a unique identifier from your other logic, you can auth the user. The same code can be used for both sign-up and sign-in, because all you're doing is translate a fixed uid into the corresponding user.

Is something similar available in Amplify?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source