This service can be used to:
root: Set the work directory for backendaccess_token: set the access_token for google drive api Please notice its expiration.If you want to let OpenDAL to refresh the access token automatically, please provide the following fields:
refresh_token: set the refresh_token for google drive apiclient_id: set the client_id for google drive apiclient_secret: set the client_secret for google drive apiOpenDAL is a library, it cannot do the first step of OAuth2 for you. You need to get authorization code from user by calling GoogleDrive's authorize url and exchange it for refresh token.
Make sure you have enabled Google Drive API in your Google Cloud Console. And your OAuth scope contains https://www.googleapis.com/auth/drive.
Please refer to GoogleDrive OAuth2 Flow for more information.
You can refer to [GdriveBuilder]'s docs for more information
use opendal_core::Operator; use opendal_core::Result; use opendal_service_gdrive::Gdrive; #[tokio::main] async fn main() -> Result<()> { let mut builder = Gdrive::default() .root("/test") .access_token("<token>"); let op: Operator = Operator::new(builder)?.finish(); Ok(()) }