Skip to content

Commit a641952

Browse files
committed
upgraded code
1 parent 165ef3d commit a641952

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

functions-python/reverse_geolocation/src/reverse_geolocation_processor.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
)
3939
from shared.helpers.logger import get_logger
4040

41-
import google.auth
42-
import google.auth.transport.requests
41+
from google.auth.transport import requests
42+
from google.auth import id_token
4343

4444

4545
@with_db_session
@@ -386,15 +386,13 @@ def extract_location_aggregates(
386386
raise ValueError("FUNCTION_URL_REFRESH_MV environment variable is not set")
387387

388388
# Create an authorized request
389-
auth_req = google.auth.transport.requests.Request()
389+
auth_req = requests.Request()
390390

391391
# Get an identity token for the target URL
392-
id_token = google.auth.id_token.fetch_id_token(auth_req, refresh_url)
392+
token = id_token.fetch_id_token(auth_req, refresh_url)
393393

394394
# Make the HTTP request with the ID token
395-
response = requests.get(
396-
refresh_url, headers={"Authorization": f"Bearer {id_token}"}
397-
)
395+
response = requests.get(refresh_url, headers={"Authorization": f"Bearer {token}"})
398396

399397
response.raise_for_status()
400398
logger.info("Materialized view refresh event triggered successfully.")

0 commit comments

Comments
 (0)