amplify-android
amplify-android copied to clipboard
Request for Auth.getPreferredMFA(...) for JavaScript parity
AWS Cognito Android SDK "GET MFA API" (getUserMfaSettingsInBackground) needed from CognitoUserPool class
Need to get the current user MFA setting as an API
In Amplify JavaScript library this get method is available.
But in Android sdk only option available is "setUserMfaSettingsInBackground".
public void setUserMfaSettingsInBackground(final List<CognitoMfaSettings> mfaSettings,
final GenericHandler callback) {
if (callback == null) {
throw new CognitoParameterInvalidException("callback is null");
}
final CognitoUserSession session = this.getCachedSession();
new Thread(new Runnable() {
@Override
public void run() {
final Handler handler = new Handler(context.getMainLooper());
Runnable returnCallback;
try {
setUserMfaSettingsInternal(mfaSettings, session);
returnCallback = new Runnable() {
@Override
public void run() {
callback.onSuccess();
}
};
} catch (final Exception e) {
returnCallback = new Runnable() {
@Override
public void run() {
callback.onFailure(e);
}
};
}
handler.post(returnCallback);
}
}).start();
}
We want to perform the SMS_MFA enable and disable provision in mobile as well as web app. I'm able to update the preferred MFA type in web and can able to get the current state on load. Same thing need to be done on android, While landing to a screen initially I need to check the current Preferred MFA type and then I will update the type.
Kindly help on this to get the get API in android SDK.
Thanks for suggesting this - we will keep it in mind here and prioritize it based on demand.
For reference, Amplify JS reads this value from some local settings. The Set*
call, though, is a Cognito service API call.
https://github.com/aws-amplify/amplify-js/blob/c27b8164995220090967f782ccd8e42ad4fa4bdb/packages/auth/src/Auth.ts#L608-L616
The SetUserMfaPreference
is a Cognito service API.
https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_SetUserMFAPreference.html
https://docs.amplify.aws/lib/auth/mfa/q/platform/android/#fetch-the-current-users-mfa-preferences
Amplify Android v2 now has the capability to fetch current MFA preferences, in addition to updating preferences!
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.