Example #1
0
        public async Task <(CloudStorageResult, CloudStorageAccountInfo)> LoginAsync()
        {
            CloudStorageResult      result      = new CloudStorageResult();
            CloudStorageAccountInfo accountInfo = new CloudStorageAccountInfo();

            try
            {
                if (await oAuthWrapper.GetTokenAsync())
                {
                    SaveAccessTokenDelegate?.Invoke(oAuthWrapper.AccessToken);
                    SaveRefreshTokenDelegate?.Invoke(oAuthWrapper.RefreshToken);
                    LastRefreshToken = oAuthWrapper.RefreshToken;
                    LastAccessToken  = oAuthWrapper.AccessToken;
                    InitDriveService();
                    (result, accountInfo.userName, accountInfo.userEmail) = await GetUserInfoAsync();

                    if (result.Status == Status.Success)
                    {
                        (result, accountInfo.usedSpace, accountInfo.totalSpace) = await GetRootInfoAsync();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Status  = Status.UnknownError;
                result.Message = ex.Message;
            }
            return(result, accountInfo);
        }