Sessions with Xamarin Secure Storage Plugin

0

Hello friends, I am developing an app that consumes a web service, my question is regarding the sessions in Xamarin , I would like to know someone could guide me on how to handle this topic, How to generate and maintain sessions in xam ?, my web service will give me a token (bearer), which I would like to use to confirm my session, but I also have to make sure that the session does not close when the application is closed or when it is not active.I read that there is a library name Secure Storage Plugin with which I understand that I can save my token and reuse it, does anyone know anything about it? . If someone could guide me or link me an example of how to do this, I would be eternally grateful: 3

    
asked by E.Rawrdríguez.Ophanim 12.02.2018 в 21:49
source

1 answer

2

The secure storage plugin is used to store data in the "encrypted" area of the phone.

In the case of iOS it can become problematic because that area is not deleted when the app is uninstalled.

If you only want to save it to have persistence from one use to another you can use Plugin.Settings that saves it in what would come to be the preferences.

In any case I am not very happy with using tokens to keep sessions in mobility.

What I usually do is that when I start the app or when I restore it, it relogs the user, to verify that their credentials are still valid. If the login is correct I let it pass transparently, and if I do not return it to the login screen and delete the credentials.

To save username and password if you should use that plugin that you comment.

EDITING

Example of using Plugin.Settings:

When you install the plugin, you create a Settings file in the Helpers folder in all the projects. If you are in forms you only need the PCL project. In this project you have properties like:

        private const string usuario = "usuario";
        public static string SettingsUsuario
        {
            get { return AppSettings.GetValueOrDefault(usuario, SettingsDefault); }
            set { AppSettings.AddOrUpdateValue(usuario, value); }
        }

From that moment you can call save or record by calling the property

But I do not know if that goes for what you want.

The "general" standard you should use is

  • User configuration that does not matter whether it is safe or not Plugin.Settings.
  • User settings that you need to save secure to Secure Storage
  • Content of the application that has use (created, deleted, updated) to Sqlite.
answered by 13.02.2018 / 18:24
source