DEV Community

KartikJha
KartikJha

Posted on • Edited on

No space on google cloud :(

If you are like me and don’t fuss about your email much but have a lot of newsletter subscriptions then you probably ran into this problem.

No space left on google cloud storage dashboard

So if you are not feeling lucky (and don’t wanna buy additional storage) and have not organized your inbox much. Then you are in luck as I ran into this same problem and have created a simple script that should take care of those unwanted senders.

Link to script

To use the script you need to get your bearer auth token from google workspace

  1. Log in to google workspace developer dashboard

  2. Go to https://developers.google.com/gmail/api/reference/rest/v1/users.messages/list

  3. Copy bearer auth token from the list request headers, look for https://content-gmail.googleapis.com/gmail/v1/users in network tab.

Network tab screenshot of network call

Now assign this auth token here, update senders based on your requirements here. I have already added some based on my requirements.

All set you are ready to go, just type

touch text.txt
node delete_messages_from_senders.js
Enter fullscreen mode Exit fullscreen mode

It will delete all the messages from listed senders and will update the text.txt file with number of messages per sender.

Happy deleting emails!

Top comments (0)