在预先建立的oAuth流程中实施FaceID或其他生物识别ID

问题描述

我正在尝试将Face ID添加到我们已经建立的登录过程中。我已阅读以下文章,可以成功评估该政策并从生物识别过程中获得成功。

我的应用程序的身份验证要求输入用户名和密码,然后ping api并返回oAuth令牌。我们将此令牌存储在会话中。该令牌最终会过期,需要刷新。当前,我们注销用户,他们输入用户名和密码,然后令牌刷新。

我的问题是如何在手机的钥匙串中存储用户名和密码,并且在成功进行生物特征识别扫描后如何获取用户名和密码?

这是我正在尝试做的事情的一个示例,只是不确定如何做或者这是否是正确的方法

https://developer.apple.com/documentation/localauthentication/logging_a_user_into_your_app_with_face_id_or_touch_id?language=objc

let reason = "Log in to your account"
context.evaluatePolicy(.deviceOwnerAuthentication,localizedReason: reason ) { success,error in

if success {

    dispatchQueue.main.async { [uNowned self] in
        //I assume here is where I would do something of the following
        let user = {access keychain to get username?}
        let pass = {access keychain to get password?}
        ApiService.callOAuthEndpointWith(username: user,password: pass,delegate: self)
    }

 }  else {
        print(error?.localizedDescription ?? "Failed to authenticate")

        // Fall back to a asking for username and password.
        // ...
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)