将 Xamarin.Auth 与自定义 endpoint/webservice 结合使用

Using Xamarin.Auth with a custom endpoint/webservice

我正在我的应用程序中实施登录身份验证。现在我正在使用一个 IOC 接口,它将我的电子邮件和密码存储在设备存储中(它使用 Android 中的 SharedPreferences 和 iOS 中的 NSUserDefault class)。当我进入登录屏幕时,我必须输入我的电子邮件和密码,然后我将该数据发送到服务器 API。服务器响应是一个身份验证令牌,在请求 "Set-Cookie" header 中设置。我必须在向服务器 API 发出的每个请求中设置此身份验证令牌。令牌在一定时间后过期,该值也出现在请求 header 中。现在基本上一切正常,但问题是,正如我们所知,在 SharedPreferences/NSUserDefaults 中保存用户电子邮件和密码等敏感数据并不是一个好主意。所以我想知道我是否可以使用 Xamarin.Auth 来实现这一点。 AFAIK Xamarin.Auth 仅适用于 Facebook、Google、OAuth 等身份提供商

这可能吗?我可以使用 Xamarin.Auth 来安全地保存这些值吗?

这绝对有效,看看 GitHub repository of Xamarin.Auth

"getting started" page 声明您可以轻松地 extend/customize Xamarin.Auth 使用您的端点:

Xamarin.Auth includes OAuth 1.0 and OAuth 2.0 authenticators, providing support for thousands of popular services. For services that use traditional username/password authentication, you can roll your own authenticator by deriving from FormAuthenticator.

If you want to authenticate against an ostensibly unsupported service, fear not – Xamarin.Auth is extensible! It's very easy to create your own authenticators – just derive from any of the existing authenticators and start overriding methods.