Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -37,21 +37,27 @@ hf_client = InferenceClient("CohereForAI/c4ai-command-r-plus", token=os.getenv("
|
|
37 |
SCOPES = ["https://www.googleapis.com/auth/youtube.force-ssl"]
|
38 |
creds = None
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
if os.path.exists(token_path):
|
41 |
creds = Credentials.from_authorized_user_file(token_path, SCOPES)
|
|
|
|
|
|
|
42 |
if not creds or not creds.valid:
|
43 |
if creds and creds.expired and creds.refresh_token:
|
44 |
creds.refresh(Request())
|
45 |
else:
|
46 |
-
|
47 |
-
creds = flow.run_console() # run_local_server 대신 run_console 사용
|
48 |
-
with open(token_path, 'w') as token:
|
49 |
-
token.write(creds.to_json())
|
50 |
-
else:
|
51 |
-
flow = InstalledAppFlow.from_client_secrets_file(credentials_path, SCOPES)
|
52 |
-
creds = flow.run_console() # run_local_server 대신 run_console 사용
|
53 |
-
with open(token_path, 'w') as token:
|
54 |
-
token.write(creds.to_json())
|
55 |
|
56 |
youtube_service = build('youtube', 'v3', credentials=creds)
|
57 |
|
|
|
37 |
SCOPES = ["https://www.googleapis.com/auth/youtube.force-ssl"]
|
38 |
creds = None
|
39 |
|
40 |
+
def authorize():
|
41 |
+
flow = InstalledAppFlow.from_client_secrets_file(credentials_path, SCOPES)
|
42 |
+
auth_url, _ = flow.authorization_url(prompt='consent')
|
43 |
+
print('Please go to this URL: {}'.format(auth_url))
|
44 |
+
code = input('Enter the authorization code: ')
|
45 |
+
flow.fetch_token(code=code)
|
46 |
+
creds = flow.credentials
|
47 |
+
with open(token_path, 'w') as token:
|
48 |
+
token.write(creds.to_json())
|
49 |
+
return creds
|
50 |
+
|
51 |
if os.path.exists(token_path):
|
52 |
creds = Credentials.from_authorized_user_file(token_path, SCOPES)
|
53 |
+
else:
|
54 |
+
creds = authorize()
|
55 |
+
|
56 |
if not creds or not creds.valid:
|
57 |
if creds and creds.expired and creds.refresh_token:
|
58 |
creds.refresh(Request())
|
59 |
else:
|
60 |
+
creds = authorize()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
youtube_service = build('youtube', 'v3', credentials=creds)
|
63 |
|