Exemplo n.º 1
0
        public async System.Threading.Tasks.Task Login()
        {
            //show login
            var user = await LoginAsync(Forms.Context, withRefreshToken: true, title: "Sign In");

            //after login, create user object.
            User toReturn = new User()
            {
                IdToken = user.IdToken,
                RefreshToken = user.RefreshToken,
                Email = user.Profile["email"].Value<string>()
            };

            //create account service and store the credentials on the device.
            var accountService = new AccountHelper(new KeyVaultStorage());
            accountService.StoreCredentials(toReturn);
            SetUser(toReturn);
        }
Exemplo n.º 2
0
	    public async System.Threading.Tasks.Task Login (){
            //get the main controller
			var controller = UIApplication.SharedApplication.KeyWindow.RootViewController;

            //show login page.
            var result = await LoginAsync(
                controller,
                withRefreshToken: true);

            //after login, create user object.
	        User toReturn = new User()
	        {
                IdToken = result.IdToken,
                RefreshToken = result.RefreshToken,
                Email = result.Profile["email"].Value<string>()
	        };

            //create account service and store the credentials on the device.
            var accountService =new AccountHelper(new SecureStorage());
            accountService.StoreCredentials(toReturn);

            //set the current user.
            SetUser(toReturn);
        }