Repository navigation
Expand file tree
/
Copy pathgoogle-api.bat
More file actions
276 lines (240 loc) · 8.68 KB
/
Copy pathgoogle-api.bat
File metadata and controls
276 lines (240 loc) · 8.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
@echo off
setlocal enabledelayedexpansion
:: API Key Forge - Google Cloud Platform
:: =====================================
color 0A
cls
echo.
echo ╔═══════════════════════════════════════════════════╗
echo ║ API Key Forge - Google Cloud ║
echo ╠═══════════════════════════════════════════════════╣
echo ║ Get credentials for Google APIs and Services ║
echo ╚═══════════════════════════════════════════════════╝
echo.
echo What would you like to set up?
echo.
echo [1] API Key (Simple, less secure)
echo [2] OAuth 2.0 Client ID (For user auth)
echo [3] Service Account Key (For server apps)
echo [4] Enable specific APIs (Drive, Sheets, etc.)
echo [5] All of the above (Full setup)
echo.
set /p choice="Enter your choice (1-5): "
if "%choice%"=="1" goto :api_key
if "%choice%"=="2" goto :oauth
if "%choice%"=="3" goto :service_account
if "%choice%"=="4" goto :enable_apis
if "%choice%"=="5" goto :full_setup
goto :invalid
:api_key
cls
echo.
echo ══════════════════════════════════════════════════════
echo Google API Key Setup
echo ══════════════════════════════════════════════════════
echo.
echo This will help you create a simple API key.
echo.
echo Press any key to open Google Cloud Console...
pause >nul
start https://console.cloud.google.com/apis/credentials
echo.
echo STEPS TO FOLLOW:
echo ----------------
echo 1. Sign in to Google Cloud Console
echo 2. Select or create a project
echo 3. Click "CREATE CREDENTIALS" → "API key"
echo 4. (Optional) Click "RESTRICT KEY" for security
echo 5. Copy your API key
echo.
echo Waiting for you to complete the steps...
echo.
:: Run Python helper if available
if exist "%~dp0helpers\google_helper.py" (
python "%~dp0helpers\google_helper.py" api_key
) else (
set /p api_key="Paste your API key here (or press Enter to skip): "
if not "!api_key!"=="" (
echo.
echo Your API key: !api_key!
echo.
echo Save this in your .env file as:
echo GOOGLE_API_KEY=!api_key!
)
)
goto :end
:oauth
cls
echo.
echo ══════════════════════════════════════════════════════
echo OAuth 2.0 Client ID Setup
echo ══════════════════════════════════════════════════════
echo.
echo This will help you create OAuth credentials for user authentication.
echo.
start https://console.cloud.google.com/apis/credentials
echo.
echo STEPS TO FOLLOW:
echo ----------------
echo 1. Click "CREATE CREDENTIALS" → "OAuth client ID"
echo 2. Configure OAuth consent screen if needed
echo 3. Choose application type:
echo - Web application (for web apps)
echo - Desktop app (for CLI tools)
echo 4. Add authorized redirect URIs if needed
echo 5. Download the credentials JSON file
echo.
set /p app_type="What type of app? (web/desktop): "
if /i "%app_type%"=="web" (
echo.
echo For web apps, common redirect URIs:
echo - http://localhost:8080/callback
echo - http://localhost:3000/auth/callback
echo - https://yourdomain.com/oauth/callback
)
echo.
echo After downloading credentials.json, place it in your project folder.
echo.
pause
goto :end
:service_account
cls
echo.
echo ══════════════════════════════════════════════════════
echo Service Account Key Setup
echo ══════════════════════════════════════════════════════
echo.
echo This will help you create a service account for server-to-server auth.
echo.
start https://console.cloud.google.com/iam-admin/serviceaccounts
echo.
echo STEPS TO FOLLOW:
echo ----------------
echo 1. Click "CREATE SERVICE ACCOUNT"
echo 2. Enter a name and description
echo 3. Grant necessary roles (e.g., "Editor" or specific API roles)
echo 4. Click "CREATE KEY" → Choose JSON
echo 5. Save the downloaded JSON file securely
echo.
echo SECURITY WARNING: This key has full access! Keep it secret!
echo.
set /p filename="What should we name the key file? (default: service-account-key.json): "
if "%filename%"=="" set filename=service-account-key.json
echo.
echo After downloading, save it as: %filename%
echo Set environment variable: GOOGLE_APPLICATION_CREDENTIALS=%cd%\%filename%
echo.
pause
goto :end
:enable_apis
cls
echo.
echo ══════════════════════════════════════════════════════
echo Enable Google APIs
echo ══════════════════════════════════════════════════════
echo.
echo Which APIs do you need to enable?
echo.
echo [1] Google Drive API
echo [2] Google Sheets API
echo [3] Google Calendar API
echo [4] Gmail API
echo [5] YouTube Data API
echo [6] Google Maps API
echo [7] Cloud Storage API
echo [8] Custom (enter manually)
echo.
set /p api_choice="Enter your choices (e.g., 1,2,3): "
start https://console.cloud.google.com/apis/library
echo.
echo Opening API Library...
echo.
echo Search and enable these APIs:
if "!api_choice:1=!" neq "!api_choice!" echo - Google Drive API
if "!api_choice:2=!" neq "!api_choice!" echo - Google Sheets API
if "!api_choice:3=!" neq "!api_choice!" echo - Google Calendar API
if "!api_choice:4=!" neq "!api_choice!" echo - Gmail API
if "!api_choice:5=!" neq "!api_choice!" echo - YouTube Data API v3
if "!api_choice:6=!" neq "!api_choice!" echo - Maps JavaScript API
if "!api_choice:7=!" neq "!api_choice!" echo - Cloud Storage API
if "!api_choice:8=!" neq "!api_choice!" (
set /p custom_api="Enter API name to search: "
echo - !custom_api!
)
echo.
pause
goto :end
:full_setup
cls
echo.
echo ══════════════════════════════════════════════════════
echo Complete Google Cloud Setup
echo ══════════════════════════════════════════════════════
echo.
echo This will guide you through the complete setup process.
echo.
echo We'll help you:
echo ✓ Create a new project
echo ✓ Enable necessary APIs
echo ✓ Create credentials
echo ✓ Test your setup
echo.
pause
:: Create project
echo Step 1: Creating a new project...
start https://console.cloud.google.com/projectcreate
echo.
echo Enter a project name and create your project.
echo Wait for it to be created, then press any key...
pause >nul
:: Enable APIs
echo.
echo Step 2: Enable APIs...
call :enable_apis
:: Create credentials
echo.
echo Step 3: Create credentials...
echo.
echo What type of credentials do you need?
echo [1] API Key only
echo [2] OAuth 2.0 only
echo [3] Service Account only
echo [4] All types
echo.
set /p cred_choice="Enter choice: "
if "%cred_choice%"=="1" call :api_key
if "%cred_choice%"=="2" call :oauth
if "%cred_choice%"=="3" call :service_account
if "%cred_choice%"=="4" (
call :api_key
call :oauth
call :service_account
)
goto :end
:invalid
echo Invalid choice. Please run the script again.
pause
exit /b 1
:end
echo.
echo ══════════════════════════════════════════════════════
echo Setup Complete!
echo ══════════════════════════════════════════════════════
echo.
echo Next steps:
echo 1. Test your credentials with test-google-api.bat
echo 2. Add credentials to your .env file
echo 3. Never commit credentials to Git!
echo.
echo Would you like to test your credentials now? (y/n)
set /p test_now="Choice: "
if /i "%test_now%"=="y" (
if exist "%~dp0test-google-api.bat" (
call "%~dp0test-google-api.bat"
) else (
echo Test script not found. Creating one...
call "%~dp0create-test-script.bat" google
)
)
echo.
pause