Hi guys. So what I'm trying to do is authenticate with Cognito to access protected endpoints on our admin backend. I've already succeeded in doing so with a custom Retool auth flow, by adding an API request to Cognito IDP with the USER_PASSWORD_AUTH flow (sending plain username and password).
Now, for security reasons this is less than ideal, so we are trying to use the USER_SRP_AUTH flow, but doing this with the API is extremely inefficient since we would have to encrypt everything locally and it's a bunch of code we don't want to reimplement.
For that reason, I'm trying to use the aws-amplify library (https://cdnjs.cloudflare.com/ajax/libs/aws-amplify/4.3.46/aws-amplify.min.js) to authenticate directly with Cognito leveraging its internal SRP calculation, but so far the library hasn't been recognized even though I'm loading it as suggested in the docs here (Preload custom JavaScript in apps | Retool Docs). Here is my code snippet:
try {
const user = await Auth.signIn(EMAIL, PASSWORD);
return {
accessToken: user.getAccessToken(),
idToken: user.getIdToken()
}
} catch (error) {
console.log('error signing in', error);
}
so basically I've tried doing import, require, etc. at the top of this to no avail and I'm getting frustrated. Does anyone have any idea if this would even be feasible and if so, how to implement it properly?
Regards,
Gonzalo.