mirror of
https://github.com/Nezumi-2711/next-gdrive-index.git
synced 2026-09-23 04:10:03 +00:00
Remove .env
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import apiConfig from "@config/api.config";
|
||||
import { google, drive_v3 } from "googleapis";
|
||||
|
||||
class DriveClient {
|
||||
private instance: drive_v3.Drive;
|
||||
|
||||
constructor() {
|
||||
const oauth2Client = new google.auth.OAuth2(
|
||||
apiConfig.client_id,
|
||||
process.env.CLIENT_SECRET,
|
||||
apiConfig.redirect_uri,
|
||||
);
|
||||
oauth2Client.setCredentials({ refresh_token: process.env.REFRESH_TOKEN });
|
||||
this.instance = google.drive({ version: "v3", auth: oauth2Client });
|
||||
}
|
||||
|
||||
getInstance() {
|
||||
if (!this.instance) {
|
||||
const oauth2Client = new google.auth.OAuth2(
|
||||
apiConfig.client_id,
|
||||
process.env.CLIENT_SECRET,
|
||||
apiConfig.redirect_uri,
|
||||
);
|
||||
oauth2Client.setCredentials({ refresh_token: process.env.REFRESH_TOKEN });
|
||||
this.instance = google.drive({ version: "v3", auth: oauth2Client });
|
||||
}
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
const drive = new DriveClient();
|
||||
|
||||
export default drive.getInstance();
|
||||
Reference in New Issue
Block a user