Using Google Service Account with Epic Backup
· 2 min read
To create a Google Service Account and use it for Google Drive API, follow these steps:
Step 1: Create a Google Cloud Project
- Go to the Google Cloud Console.
- Click on the project drop-down at the top and select "New Project".
- Enter a project name (e.g.,
Drive API Project). - Click "Create" and wait for the project to be created.
Step 2: Enable Google Drive API
- Inside the Google Cloud Console, go to "APIs & Services" > "Library".
- Search for Google Drive API and click on it.
- Click "Enable".
Step 3: Create a Service Account
- Go to "IAM & Admin" > "Service Accounts".
- Click "Create Service Account".
- Enter a Service Account Name (e.g.,
drive-api-service). - Click "Create and Continue".
- Assign the role "Editor" or "Owner" (or select "Cloud Storage Admin" if needed).
- Click "Continue", then "Done".
Step 4: Generate JSON Key
- In the Service Accounts list, click on the created service account.
- Go to the "Keys" tab.
- Click "Add Key" > "Create new key".
- Select "JSON" and click "Create".
- A JSON file will be downloaded—this contains your service account credentials.
Step 5: Share Google Drive Access with Service Account
- Open Google Drive.
- Create a folder where the service account will store files.
- Right-click on the folder > "Share".
- Copy the email from the service account JSON file (it looks like
your-service@your-project.iam.gserviceaccount.com). - Paste it into the Share with people and groups field.
- Set permissions to "Editor" and click "Send".
Step 6: Use Service Account in Code
You can now use the JSON key file in your application to authenticate with Google Drive API.
Reference: https://support.google.com/a/answer/7378726