Spaces:
Running
Running
Create credentials_creation.py
Browse files- credentials_creation.py +25 -0
credentials_creation.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import json
|
3 |
+
|
4 |
+
def create_credentials():
|
5 |
+
# Read Google OAuth credentials from environmental variables
|
6 |
+
GOOGLE_CLIENT_ID = os.getenv('GOOGLE_CLIENT_ID')
|
7 |
+
GOOGLE_CLIENT_SECRET = os.getenv('GOOGLE_CLIENT_SECRET')
|
8 |
+
|
9 |
+
# The credentials.json structure expected by Google's OAuth
|
10 |
+
credentials_data = {
|
11 |
+
"web":{
|
12 |
+
"client_id":GOOGLE_CLIENT_ID,
|
13 |
+
"project_id":"resume-tailoring-436517",
|
14 |
+
"auth_uri":"https://accounts.google.com/o/oauth2/auth",
|
15 |
+
"token_uri":"https://oauth2.googleapis.com/token",
|
16 |
+
"auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs",
|
17 |
+
"client_secret":GOOGLE_CLIENT_SECRET
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
# Write the credentials data to a temporary JSON file
|
22 |
+
with open('credentials.json', 'w') as credentials_file:
|
23 |
+
json.dump(credentials_data, credentials_file)
|
24 |
+
|
25 |
+
# Now, this generated credentials.json file can be used for the OAuth flow in the app
|