Beispiel #1
0
        public async Task <ActionResult> RegisterGoogleDrive(string gdCode)
        {
            int accountId = JWTUtility.GetIdFromRequestHeaders(Request.Headers);

            if (accountId == -1)
            {
                return(BadRequest());
            }

            using var stream = new FileStream("googleDriveSecrets.json", FileMode.Open, FileAccess.Read);

            IAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
            {
                ClientSecretsStream = stream,
                Scopes    = _gdScopes,
                DataStore = _dataStore
            });

            var response = await flow.ExchangeCodeForTokenAsync(
                accountId.ToString(),
                gdCode,
                _config.GetValue <string>("GDRedirectURL"),
                CancellationToken.None
                );

            await _migService.GoogleDriveMigrationAsync(accountId);

            return(Ok());
        }