Skip to content Skip to sidebar Skip to footer

How To Get And Pass DeviceKey In Social Login Using Cognito And AWS Amplify?

I am trying to use the function setDeviceStatusRemembered from Cognito in the social login, but it needs a deviceKey, which is not available in the user object returned. The projec

Solution 1:

First of all, make sure that your user pool is configured to remember devices. If you set up Auth through Amplify this is probably off by default. Here's how it is enabled in the AWS console:

Screenshot AWS console

You can get the device key from the user object:

Auth.currentAuthenticatedUser({
}).then(user => {
  user.getCachedDeviceKeyAndPassword(); // without this line, the deviceKey is null
  console.log(user.deviceKey);
});

Post a Comment for "How To Get And Pass DeviceKey In Social Login Using Cognito And AWS Amplify?"