/// <summary>
        ///     Create and persist Account for newly authenticated user
        /// </summary>
        /// <param name="loginOptions"></param>
        /// <param name="authResponse"></param>
        public static async Task<Account> CreateNewAccount(LoginOptions loginOptions, AuthResponse authResponse)
        {
            LoggingService.Log("Create account object", LoggingLevel.Verbose);

            var account = new Account(
                loginOptions.LoginUrl, 
                loginOptions.ClientId, 
                loginOptions.CallbackUrl,
                loginOptions.Scopes,
                authResponse.InstanceUrl, 
                authResponse.IdentityUrl, 
                authResponse.AccessToken, 
                authResponse.RefreshToken)
            {
                CommunityId = authResponse.CommunityId,
                CommunityUrl = authResponse.CommunityUrl
            };

            var cm = new ClientManager();
            cm.PeekRestClient();
            IdentityResponse identity = null;
            try
            {
                identity = await OAuth2.CallIdentityServiceAsync(authResponse.IdentityUrl, authResponse.AccessToken);
            }
            catch (JsonException ex)
            {
                LoggingService.Log("Exception occurred when retrieving account identity:",
                    LoggingLevel.Critical);
                LoggingService.Log(ex, LoggingLevel.Critical);
                Debug.WriteLine("Error retrieving account identity");
            }

            if (identity != null)
            {
                account.UserId = identity.UserId;
                account.UserName = identity.UserName;
                account.Policy = identity.MobilePolicy;
                account.OrganizationId = identity.OrganizationId;

                await AuthStorageHelper.PersistCurrentAccountAsync(account);

                LoggedInAccount = account;
            }
            LoggingService.Log("Finished creating account", LoggingLevel.Verbose);
            return account;
        }
 /// <summary>
 ///     Create and persist Account for newly authenticated user
 /// </summary>
 /// <param name="loginOptions"></param>
 /// <param name="authResponse"></param>
 public static async Task<Account> CreateNewAccount(LoginOptions loginOptions, AuthResponse authResponse)
 {
     PlatformAdapter.SendToCustomLogger("AccountManager.CreateNewAccount - create account object", LoggingLevel.Verbose);
     var account = new Account(loginOptions.LoginUrl, loginOptions.ClientId, loginOptions.CallbackUrl,
         loginOptions.Scopes,
         authResponse.InstanceUrl, authResponse.IdentityUrl, authResponse.AccessToken, authResponse.RefreshToken);
     account.CommunityId = authResponse.CommunityId;
     account.CommunityUrl = authResponse.CommunityUrl;
     var cm = new ClientManager();
     cm.PeekRestClient();
     IdentityResponse identity = null;
     try
     {
         identity = await OAuth2.CallIdentityService(authResponse.IdentityUrl, authResponse.AccessToken);
     }
     catch (JsonException ex)
     {
         PlatformAdapter.SendToCustomLogger(
             "AccountManager.CreateNewAccount - Exception occurred when retrieving account identity:",
             LoggingLevel.Critical);
         PlatformAdapter.SendToCustomLogger(ex, LoggingLevel.Critical);
         Debug.WriteLine("Error retrieving account identity");
     }
     if (identity != null)
     {
         account.UserId = identity.UserId;
         account.UserName = identity.UserName;
         account.Policy = identity.MobilePolicy;
         AuthStorageHelper.GetAuthStorageHelper().PersistCredentials(account);
     }
     PlatformAdapter.SendToCustomLogger("AccountManager.CreateNewAccount - done", LoggingLevel.Verbose);
     return account;
 }
        /// <summary>
        /// Create and persist Account for newly authenticated user
        /// </summary>
        /// <param name="loginOptions"></param>
        /// <param name="authResponse"></param>
        public async static Task<bool> CreateNewAccount(LoginOptions loginOptions, AuthResponse authResponse)
        {
            Account account = new Account(loginOptions.LoginUrl, loginOptions.ClientId, loginOptions.CallbackUrl, loginOptions.Scopes,
                authResponse.InstanceUrl, authResponse.IdentityUrl, authResponse.AccessToken, authResponse.RefreshToken);
            var cm = new ClientManager();
            var client = cm.PeekRestClient();
            IdentityResponse identity = await OAuth2.CallIdentityService(authResponse.IdentityUrl, authResponse.AccessToken);

            if (identity != null)
            {
                account.UserId = identity.UserId;
                account.UserName = identity.UserName;
                AuthStorage.PersistCredentials(account);
                return true;
            }
            return false;
        }