fix invalid_scope error on token refresh

Requesting a narrower scope explicitly (scopes=[...]) during refresh
was rejected by Google as invalid_scope in the Airflow container's
google-auth version, even though it worked locally with a newer one.
Drop scopes= entirely — the refresh_token already carries the full
granted scope (calendar + gmail.send), no need to request a subset.
This commit is contained in:
Power BI Dev
2026-07-27 22:16:31 +07:00
parent e0a6efd204
commit 7a6dc7d9ae
2 changed files with 10 additions and 2 deletions
+4 -1
View File
@@ -127,13 +127,16 @@ class GoogleCalendarService:
def __init__(self, config: GoogleConfig):
self._calendar_id = config.calendar_id
# Sengaja TIDAK set `scopes=` — lihat catatan di GmailService.__init__
# (edoxid_calendar_gmail.py) soal `invalid_scope` yang muncul di
# container Airflow (google-auth versi lain) saat scope refresh
# diminta lebih sempit dari yang tercakup refresh_token aslinya.
creds = Credentials(
token=None,
refresh_token=config.refresh_token,
token_uri="https://oauth2.googleapis.com/token",
client_id=config.client_id,
client_secret=config.client_secret,
scopes=["https://www.googleapis.com/auth/calendar"],
)
creds.refresh(Request())