Я хочу создать что-то с помощью API Календаря Google и сейчас пытаюсь все это настроить. Я создал проект в Google Cloud Console и установил для него внешний статус со статусом «Тест». Я установил URI перенаправления на http://localhost:8080/.
Но если мой код запустится и попытается авторизоваться, я получу ошибку:
Доступ заблокирован: ошибка авторизации
Отсутствует обязательный параметр: redirect_uri
Это мой код:
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
import subprocess
SCOPES = ['https://www.googleapis.com/auth/calendar']
chrome_path = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
profile_dir = r'C:\Users\aprin\AppData\Local\Google\Chrome\User Data'
profile_name = 'Profile 4'
def open_chrome_with_profile(url):
print("open_chrome_with_profile wird aufgerufen.")
command = [chrome_path, '--profile-directory=' + profile_name, '--user-data-dir=' +
profile_dir, url]
print(f"Ausgeführter Befehl: {command}")
try:
subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except Exception as e:
print(f"Fehler beim Starten von Chrome: {e}")
def authenticate_and_create_event():
print("authenticate_and_create_event wird aufgerufen.")
flow = InstalledAppFlow.from_client_secrets_file('credentials.json', SCOPES)
auth_url, _ = flow.authorization_url(access_type='offline',
include_granted_scopes='true')
print(f"Bitte besuche diesen Link zur Autorisierung: {auth_url}")
open_chrome_with_profile(auth_url)
redirect_uri = 'http://localhost'
creds = flow.run_local_server(port=8080, redirect_uri=redirect_uri)
*service = build('calendar', 'v3', credentials=creds)
event = {
'summary': 'Meeting mit dem Team',
'start': {'dateTime': '2025-01-10T10:00:00+01:00'},
'end': {'dateTime': '2025-01-10T11:00:00+01:00'},
}
event_result = service.events().insert(calendarId='primary', body=event).execute()
print(f"Event erstellt: {event_result['htmlLink']}")
if __name__ == '__main__':
print("Programm startet.")
authenticate_and_create_event()*
Подробнее здесь: https://stackoverflow.com/questions/793 ... th-problem
Отсутствует обязательный параметр: redirect_uri: проблема Google API OAuth. ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Laravel Socialite — не удалось войти в Google «Отсутствует обязательный параметр: код»
Anonymous » » в форуме Php - 0 Ответы
- 18 Просмотры
-
Последнее сообщение Anonymous
-