{"id":8951,"date":"2022-01-04T21:47:05","date_gmt":"2022-01-04T21:47:05","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=8951"},"modified":"2022-01-04T21:47:05","modified_gmt":"2022-01-04T21:47:05","slug":"secure-storage-using-xamarin-essentials","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/secure-storage-using-xamarin-essentials\/","title":{"rendered":"Secure storage using Xamarin Essentials"},"content":{"rendered":"<p>In my post <a href=\"http:\/\/putridparrot.com\/blog\/fingerprint-and-biometrics-authentication-in-xamarin-forms\/\" rel=\"noopener\" target=\"_blank\">Fingerprint and biometrics authentication in Xamarin Forms<\/a> I looked at using biometrics (face id\/touch id) to authenticate a user. <\/p>\n<p>Using biometrics is pretty useful, but ultimately we&#8217;d usually want to use the biometrics along with some way of storing a token, password or whatever. In other words the usual pattern would be something like this<\/p>\n<ul>\n<li>Request the user login details and then ask if the user wishes to use biometrics to log into your application (as this post is about using biometrics etc. let&#8217;s assume the user does indeed want to use biometrics)<\/li>\n<li>Store the token or other details for the successful login within secure storage<\/li>\n<li>When the user next try to log into your application, offer an option to use the password to login but by default give an option to login via biometrics<\/li>\n<li>Assuming the user selects biometrics, then use the previously show code for biometric authorisations<\/li>\n<li>Upon success of the biometrics authorisation, get the token\/password etc. from the secure storage and use that to connect to your application\/service<\/li>\n<\/ul>\n<p>So how do we use secure storage within Xamarin forms. The Xamarin Essential nuget package give us <em>SetAsync<\/em>, for example<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nawait Xamarin.Essentials.SecureStorage.SetAsync(key, token);\r\n<\/pre>\n<p>and to read back from the storage we use <em>GetAsync<\/em>, for example<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nvar token = Xamarin.Essentials.SecureStorage.GetAsync(key);\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In my post Fingerprint and biometrics authentication in Xamarin Forms I looked at using biometrics (face id\/touch id) to authenticate a user. Using biometrics is pretty useful, but ultimately we&#8217;d usually want to use the biometrics along with some way of storing a token, password or whatever. In other words the usual pattern would be [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[122],"tags":[],"class_list":["post-8951","post","type-post","status-publish","format-standard","hentry","category-xamarin-forms"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8951","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=8951"}],"version-history":[{"count":4,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8951\/revisions"}],"predecessor-version":[{"id":9068,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8951\/revisions\/9068"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=8951"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=8951"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=8951"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}