from google.cloud import tasks_v2 def create_task(): project = '{{ __project__ }}' location = '{{ __location__ }}' queue_name = '{{ __queue_name__ }}' url = 'https://sample.com' service_account_email='{{ __service_account_email__ }}' client = tasks_v2.CloudTasksClient() task = tasks_v2.Task( http_request=tasks_v2.HttpRequest( http_method=tasks_v2.HttpMethod.GET, url=url, headers={"Content-type": "application/json"}, oidc_token=tasks_v2.OidcToken( service_account_email=service_account_email, ), ), ) return client.create_task( tasks_v2.CreateTaskRequest( parent=client.queue_path(project, location, queue_name), task=task, ) ) create_task()