private async Task<string> GetRefreshToken(AddSyncTarget request)
        {
            var config = _configurationRetriever.GetGeneralConfiguration();
            var redirectUri = request.RedirectUri;

            var token = await _googleAuthService.GetToken(request.Code, redirectUri, config.GoogleDriveClientId, config.GoogleDriveClientSecret, CancellationToken.None);
            return token.refresh_token;
        }
Esempio n. 2
0
        private async Task <string> GetRefreshToken(AddSyncTarget request)
        {
            var config      = _configurationRetriever.GetGeneralConfiguration();
            var redirectUri = request.RedirectUri;

            var token = await _googleAuthService.GetToken(request.Code, redirectUri, config.GoogleDriveClientId, config.GoogleDriveClientSecret, CancellationToken.None);

            return(token.refresh_token);
        }
Esempio n. 3
0
        public async Task Post(AddSyncTarget request)
        {
            var config       = _configurationRetriever.GetGeneralConfiguration();
            var refreshToken = await GetRefreshToken(request);

            var syncAccount = new GoogleDriveSyncAccount
            {
                Id   = Guid.NewGuid().ToString(),
                Name = WebUtility.UrlDecode(request.Name),
                EnableForEveryone = request.EnableForEveryone,
                UserIds           = request.UserIds,
                RefreshToken      = refreshToken,
                FolderId          = await GetOrCreateFolder(config.GoogleDriveClientId, config.GoogleDriveClientSecret, refreshToken)
            };

            if (!string.IsNullOrEmpty(request.Id))
            {
                syncAccount.Id = request.Id;
            }

            _configurationRetriever.AddSyncAccount(syncAccount);
        }
        public async Task Post(AddSyncTarget request)
        {
            var config = _configurationRetriever.GetGeneralConfiguration();
            var refreshToken = await GetRefreshToken(request);

            var syncAccount = new GoogleDriveSyncAccount
            {
                Id = Guid.NewGuid().ToString(),
                Name = WebUtility.UrlDecode(request.Name),
                EnableForEveryone = request.EnableForEveryone,
                UserIds = request.UserIds,
                RefreshToken = refreshToken,
                FolderId = await GetOrCreateFolder(config.GoogleDriveClientId, config.GoogleDriveClientSecret, refreshToken)
            };

            if (!string.IsNullOrEmpty(request.Id))
            {
                syncAccount.Id = request.Id;
            }

            _configurationRetriever.AddSyncAccount(syncAccount);
        }