@@ -32,7 +32,6 @@ extern crate yup_oauth2 as oauth2;
32
32
use clap:: { Arg , ArgAction , ArgMatches , Command } ;
33
33
use drive3:: DriveHub ;
34
34
use log:: { self , error, info} ;
35
- use oauth2:: { InstalledFlowAuthenticator , InstalledFlowReturnMethod } ;
36
35
use rusty_hog_scanner:: { SecretScanner , SecretScannerBuilder } ;
37
36
use rusty_hogs:: google_scanning:: { GDriveFileInfo , GDriveScanner } ;
38
37
use simple_error:: SimpleError ;
@@ -136,33 +135,25 @@ async fn run(arg_matches: ArgMatches) -> Result<(), SimpleError> {
136
135
. get_one :: < String > ( "OAUTHSECRETFILE" )
137
136
. map ( |s| s. as_str ( ) )
138
137
. unwrap_or ( "clientsecret.json" ) ;
139
- let oauthtokenfile = arg_matches
140
- . get_one :: < String > ( "OAUTHTOKENFILE" )
141
- . map ( |s| s. as_str ( ) )
142
- . unwrap_or ( "temp_token" ) ;
143
138
let file_id = arg_matches. get_one :: < String > ( "GDRIVEID" ) . unwrap ( ) ;
144
139
let secret_scanner = SecretScannerBuilder :: new ( ) . conf_argm ( & arg_matches) . build ( ) ;
145
140
let gdrive_scanner = GDriveScanner :: new_from_scanner ( secret_scanner) ;
146
141
147
142
// Start with GDrive auth - based on example code from drive3 API and yup-oauth2
148
- let secret = yup_oauth2:: read_application_secret ( Path :: new ( oauthsecretfile) )
143
+ // https://docs.rs/google-drive3/latest/google_drive3/
144
+ let secret = drive3:: oauth2:: read_application_secret ( Path :: new ( oauthsecretfile) )
149
145
. await
150
146
. expect ( oauthsecretfile) ;
151
- let auth = InstalledFlowAuthenticator :: builder ( secret, InstalledFlowReturnMethod :: HTTPRedirect )
152
- . persist_tokens_to_disk ( Path :: new ( oauthtokenfile) )
153
- . build ( )
154
- . await
155
- . expect ( "failed to create authenticator (try deleting temp_token and restarting)" ) ;
156
- let hub = DriveHub :: new (
157
- hyper:: Client :: builder ( ) . build (
158
- hyper_rustls:: HttpsConnectorBuilder :: new ( )
159
- . with_native_roots ( )
160
- . https_only ( )
161
- . enable_all_versions ( )
162
- . build ( ) ,
163
- ) ,
164
- auth,
165
- ) ;
147
+ // Instantiate the authenticator. It will choose a suitable authentication flow for you,
148
+ // unless you replace `None` with the desired Flow.
149
+ // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
150
+ // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
151
+ // retrieve them from storage.
152
+ let auth = drive3:: oauth2:: InstalledFlowAuthenticator :: builder (
153
+ secret,
154
+ drive3:: oauth2:: InstalledFlowReturnMethod :: HTTPRedirect ,
155
+ ) . build ( ) . await . unwrap ( ) ;
156
+ let mut hub = DriveHub :: new ( hyper:: Client :: builder ( ) . build ( hyper_rustls:: HttpsConnectorBuilder :: new ( ) . with_native_roots ( ) . https_or_http ( ) . enable_http1 ( ) . build ( ) ) , auth) ;
166
157
167
158
// get some initial info about the file
168
159
let gdriveinfo = GDriveFileInfo :: new ( file_id, & hub) . await . unwrap ( ) ;
0 commit comments