public async void Init(AuthDialog dialogHost)
        {
            this.dialogHost = dialogHost;

            IsLoading      = true;
            LoadingMessage = "Please press Link button on your Hue Bridge within 1 minute... We will discover it automatically for you.";

            try
            {
                var user = await HueAuthClient.RegisterHueBridge();

                AccountManager.SaveUserToVault(user);
                AppGlobalVariables.Users.Add(user);
                Debugger.WriteDebugLog("Successfully discovered Hue bridge " + user.Bridge.Config.BridgeId + " at " + user.Bridge.Config.IpAddress + ".");

                dialogHost.Hide();
            }
            catch (Exception ex)
            {
                Debugger.WriteErrorLog("Failed to add Hue Bridge.", ex);
                var message = new MessageDialog("Failed to discover Hue Bridge. Exception=" + ex.GetType().ToString() + ex.Message);
                await message.ShowAsync();

                dialogHost.Hide();
            }
        }
        public static async Task <UserBase> AcquireUserFromToken(TokenBase token)
        {
            try
            {
                switch (token.UserType)
                {
                case UserType.Google:
                    var googleClient = new GoogleClient(token);
                    return(await googleClient.GetUserDataAsync());

                case UserType.Microsoft:
                    var msClient = new MicrosoftClient(token);
                    return(await msClient.GetUserDataAsync());

                case UserType.NatureRemo:
                    var remoClient = new NatureRemoClient(token);
                    return(await remoClient.GetUserDataAsync());

                case UserType.Hue:
                    return(await HueAuthClient.FindHueBridge(token));

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                Debugger.WriteErrorLog("Exception occured on acquiring user info. Type=" + token.UserType.ToString(), ex);
                //var message = new MessageDialog("Type=" + token.UserType.ToString() + " Exception=" + ex.Message, "Exception occured on acquiring user info.");
                //await message.ShowAsync();
                var user = new UserBase();
                user.Token             = token;
                user.UserType          = token.UserType;
                user.UserName          = "******";
                user.ProfilePictureUrl = "/Assets/Square150x150Logo.scale-200.png";
                user.Id = token.Id;

                return(user);
            }
            return(null);
        }