Exemple #1
0
        public GoogleFileManager(IGoogleApiDataStoreBL GoogleApiDataStoreBL)
        {
            _GoogleApiDataStoreBL = GoogleApiDataStoreBL;
            _logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

            _service = GoogleAuthentication.CreateServie(_GoogleApiDataStoreBL);
            _logger.Debug("finish autenticacion google drive");
        }
Exemple #2
0
        public static DriveService CreateServie(IGoogleApiDataStoreBL GoogleApiDataStoreBL)
        {
            var tokenResponse = new TokenResponse
            {
                AccessToken  = GetAccessToken().access_token,
                RefreshToken = ConfigurationManager.AppSettings["googleDriveRefreshToken"]
            };

            string[] scopes = { DriveService.Scope.Drive,                 // view and manage your files and documents
                                DriveService.Scope.DriveAppdata,          // view and manage its own configuration data
                                DriveService.Scope.DriveAppsReadonly,     // view your drive apps
                                DriveService.Scope.DriveFile,             // view and manage files created by this app
                                DriveService.Scope.DriveMetadataReadonly, // view metadata for files
                                DriveService.Scope.DriveReadonly,         // view files and documents on your drive
                                DriveService.Scope.DriveScripts };        // modify your app scripts

            //string folder = ConfigurationManager.AppSettings["isTestGoogleDrive"] != "1" ? HttpContext.Current.Server.MapPath("/App_Data/Drive.Auth.Store") : Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName, @"App_Data\Drive.Auth.Store");

            var apiCodeFlow = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
            {
                ClientSecrets = new ClientSecrets
                {
                    ClientId     = ConfigurationManager.AppSettings["googleClientId"],
                    ClientSecret = ConfigurationManager.AppSettings["googleClientSecret"]
                },
                Scopes    = scopes,
                DataStore = new DatabaseDataStore(GoogleApiDataStoreBL)
            });

            var credential = new UserCredential(apiCodeFlow, ConfigurationManager.AppSettings["googleApplicationName"], tokenResponse);


            var service = new DriveService(new BaseClientService.Initializer
            {
                HttpClientInitializer = credential,
                ApplicationName       = ConfigurationManager.AppSettings["googleApplicationName"]
            });

            return(service);
        }
Exemple #3
0
 public DatabaseDataStore(IGoogleApiDataStoreBL GoogleApiDataStoreBL)
 {
     _GoogleApiDataStoreBL = GoogleApiDataStoreBL;
 }