Introduction |
Hi guys. How to Extract Emails From Service Account (SA) Files is our topic for today. There are several ways to successfully accomplish this. It’s been a while I published any posts on here. I have been overwhelmed with some other activities. Without much ado, let’s dive in.
Well I assume we are all familiar with what Service Accounts (SA) are. Just to briefly recap, SA function like your regular google mail accounts and can be used to bypass the daily upload limit set by Google at 750 GB. Using AutoRclone or Folderclone we can generate SA to use in our projects when we wish to bypass this daily limit. Each Google account can create a maximum of 12 projects and each project can in turn generate a maximum of 100 SA. This in effect means each project can be used to upload up to (750GB multiplied by 100) 75 TB of data daily. Now imagine what you can accomplish if you have up to 12 projects, all with SA.
We need to add the SA emails to a Google Group when we want to make use of the SA in our Autorclone, Gclone, Fclone projects. Using these methods you can easily extract the Email addresses from the SA and then copy them to add into the Google Group. The Google Group email is then added to our Team Drive as a member. this is a cleaner and more tidy way of going about it instead of adding each SA individually to the Team Drive.

How to Extract Emails From Service Account (SA) Files | Method 1
First ensure you have Powershell installed on your PC. You can download it from the Microsoft Powershell Github release page. Click to expand the assets section and download the version and arcitecture of your choice. On Windows PC, navigate to the accounts
folder containing your SA files. Right-click on an empty space inside the folder and select to open Powershell
within this folder. Copy and paste in the following code and then press Enter
.
(Select-String -Path *json -Pattern 'client_email').Line | Set-Content SA_Emails1.txt
This will generate a file named SA_Emails1.txt
within the accounts
containing all the email addresses of your SA files. If you want, you can further edit the file to only show your SA email addresses. To do this, open the SA_Emails1.txt
file using Notepad++. Click Control + H
key. In the Find what
box, copy and paste this phrase into it "client_email": "
Leave the Replace with
box empty and Search mode
should be set to Normal
. Then click on Replace all
. Repeat this Find and Replace process by copying and replacing this phrase ",
You now have a SA_Emails1.txt
file containing only the SA emails which you can use by adding them to your Google Group.
How to Extract Emails From Service Account (SA) Files | Method 2
This second method works with Git Bash on Windows. Ensure you have Git installed on your PC. Open the Git bash and navigate to the folder containing the SA files. Copy and paste the following code and then press Enter.
grep -oPh '"client_email": "\K[^"]+' *.json > SA_Emails2.txt
This will generate a file named SA_Emails2.txt
within the accounts
containing all the email addresses of your SA files.
How to Extract Emails From Service Account (SA) Files | Method 3
This second method works with Git Bash or WSL on Windows. Ensure you have Git installed or WSL on your PC. Open the Git bash and navigate to the folder containing the SA files. Copy and paste the following code and then press Enter.
cat $path/*.json | grep "client_email" | awk '{print $2}'| tr -d ',"' | sed 'N;N;N;N;N;N;N;N;N;/^$/d;G' > path/SA_Emails3.txt
Where Path = the directory where the json file is located. This is variable, depending on each user. Also, remember that there is a difference between Windows and Linux in terms of path separator for directories/folders. Linux uses forward slash /
, while Windows uses a backward slash \
. In addition, Linux is case sensitive.
To illustrate this, my path on my PC will look like this:
Windows cmd shell C:\Users\ETTM\Videos\AutoRclone-ettmrclone1\accounts
Git Bash shell C:/Users/ETTM/Videos/AutoRclone-ettmrclone1/accounts
After running this code, a file named SA_Emails3.txt
is created in the accounts folder, containing all your SA emails separated by a blank line after every 10 emails. This makes it easier to copy the emails 10 at a time for use in your Google Groups, since we can only add 10 emails at a time in Google Group with a maximum of 100 emails added daily.
How to Extract Emails From Service Account (SA) Files | Method 4
This is arguably the simplest of all. I intentionally left the best for the last. All you need to do is download this executable file by FeiFan. Place it in the folder containing your SA files and double click it. It will extract the emails from all the SA present in the folder and save them in a text file named user.txt
.
EduTechTainMent Video Guide
Conclusion
That’s it guys. Now you have several options to choose from while extracting emails from your Service Acoounts (SA). Visit EduTechTainMent for more of such informative posts.