mirror of
https://github.com/not-lucky/GeminiKeyManagement.git
synced 2025-12-06 08:44:01 +05:30
1e69ced5da3a5e3ee5d1c81d3edb37d195627232
Gemini Key Management
This script automates the process of creating Google Cloud API keys for the Generative Language API (Gemini) across multiple Google Cloud projects.
Prerequisites
- Python 3.12 or higher
- A Google Cloud account and project
Setup
-
Create OAuth Client ID credentials:
- Go to the Google Cloud Console.
- Click on Create Credentials and select OAuth client ID.
- Select Desktop app as the application type.
- Give it a name and click Create.
- Download the JSON file and save it as
credentials.jsonin the root of this project.
-
Install dependencies:
pip install -r requirements.txt(Note: A
requirements.txtfile will be generated in a later step) -
Create
emails.txtfile:- Create a file named
emails.txtin the root of the project. - Add the email addresses of the Google accounts you want to process, one email per line.
- Create a file named
Usage
Run the script from your terminal:
python main.py
The first time you run the script for a new email address, you will be prompted to authenticate with your Google account in your web browser. A token file will be saved in the credentials directory for future runs.
The script will then:
- Find all Google Cloud projects accessible by the authenticated user.
- Enable the
generativelanguage.googleapis.comAPI for each project. - Create a new API key named "Gemini API Key" with restrictions to the Generative Language API.
- Save the API key to a file named
<email>.key.
Description
Languages
Python
100%