realtebo
realtebo

Reputation: 25661

AWS amplify with custom UI: how to return a code?

We implemented a custom ui with amplify (gen 1) logging against a cognitor user pool + some lambdas for migrate user from previous user database, etc...

A customer asked to be able to login interface with a response_type=code param.

We are using these, to return id token

import { signIn, fetchAuthSession } from "aws-amplify/auth";

How can login to cognito returning a code?

We tried

const params = {
                        AuthFlow: "USER_PASSWORD_AUTH", 
                        ClientId: "......"
                        AuthParameters: {
                            USERNAME: user.email,
                            PASSWORD: password,
                        },
                    };

                    const cognito = new AWS.CognitoIdentityServiceProvider();

                    cognito.initiateAuth(params, (err, data) => {
                        setIsLoading(false);
                        setError(err);

                        console.log("data", data);
                        console.log("err", err);
                         ...
                    });

but this is returning access and refresh token

Upvotes: 0

Views: 15

Answers (0)

Related Questions