protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.MyButton);
            TextView message = FindViewById<TextView>(Resource.Id.textView1);

            message.Text = "system waiting";

            ServiceWrapper sw = new ServiceWrapper();

            button.Click += async (sender, e) =>
            {
                message.Text = "Firing call to the Authorization Server";
                TokenModel tokenModel = await sw.GetAuthorizationTokenData();
                //var tokenData = JsonConvert.DeserializeObject<dynamic>(content);
                //var token = tokenData.access_token.ToString();

                message.Text = "token received : " + tokenModel.access_token;
            };
        }
        public async static void RefreshAuthenticationToken(ServiceWrapper serviceWrapper)
        {            
            var storedTokenData = NSUserDefaults.StandardUserDefaults.StringForKey("authenticationToken");

            if (storedTokenData != null)
            {
                var authenticationToken = new AuthenticationToken(storedTokenData);

                if (!authenticationToken.IsStillValid(DateTime.Now))
                {
                    TokenModel tokenModel = await serviceWrapper.GetAuthorizationTokenData();
                    NSUserDefaults.StandardUserDefaults.SetString(JsonConvert.SerializeObject(tokenModel), "authenticationToken");
                }    
            }
            else
            {
                TokenModel tokenModel = await serviceWrapper.GetAuthorizationTokenData();
                NSUserDefaults.StandardUserDefaults.SetString(JsonConvert.SerializeObject(tokenModel), "authenticationToken");
            }
            
        }
        async partial void btnRegister_TouchUpInside(UIButton sender)
        {
            lblRegisterFormFeedback.Text = "contacting API, please wait ...";
            lblRegisterFormFeedback.TextColor = UIColor.Blue;

            UserLoginModel model = new UserLoginModel(txtRegisterUsername.Text, txtRegisterPassword.Text);

            if (!model.IsValid())
            {
                lblRegisterFormFeedback.Text = "please fill in your details";
                lblRegisterFormFeedback.TextColor = UIColor.Red;
                return;
            }

            ServiceWrapper serviceWrapper = new ServiceWrapper();

            TokenModel tokenModel = await serviceWrapper.GetAuthorizationTokenData();
            string authenticationResult = await serviceWrapper.RegisterUser(model, tokenModel.access_token);

            lblRegisterFormFeedback.Text = authenticationResult;
            lblRegisterFormFeedback.TextColor = UIColor.Blue;
            
        }