Load WhatsApp chat from Google Drive¶
To load chats from google drive, install the library with the corresponding extension (ignore the
--upgrade option if you haven’t installed the library):
pip install whatstk[gdrive] --upgrade
You can also load a file saved in your Google Drive. Note that in order to do so, you need first to configure the credentials to interact with Google Drive.
In particular, you need the client secret JSON file. This can be downloaded from th Google Console. To get this file, we recommend following this tutorial, which is inspired by PyDrive2 documentation. Some important additions to previous tutorials are:
- Make sure to add yourself in Test users, as noted in this thread
- Select Desktop App instead of Web Application as the application type when creating the OAuth Client ID.
Once you have downloaded the clients secrets, run
gdrive_init, which will
guide you through the Authentification process. You will need to access a link via your browser and copy paste a
>>> from whatstk.utils import gdrive_init >>> gdrive_init("path/to/client_secrets.json") Go to the following link in your browser: https://accounts.google.com/... Enter verification code:
This should only be run the first time to correctly configure your Google credentials.
Load a file from Google Drive¶
Now, simply copy
[FILE-ID] and run:
>>> from whatstk import WhatsAppChat >>> chat = WhatsAppChat.from_source("gdrive://[FILE-ID]")
Note that Google Drive file IDs are passed with prefix gdrive://.