Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
feat: Set audience field in authenticated HTTP task example (#138)
Browse files Browse the repository at this point in the history
* Add explicit `audience1 field

Unset `audience` will be take the URL as default value. When there are query and fragment parts, this would lead to authentication errors (401).

* Add explicit `audience1 field

feat: Set `audience` in authenticated HTTP task

Unset `audience` will be take the URL as default value. When there are query and fragment parts, this would lead to authentication errors (401).

* feat: Add explicit `audience1 field

Unset `audience` will be take the URL as default value. When there are query and fragment parts, this would lead to authentication errors (401).
  • Loading branch information
ehsan-karamad authored Jul 21, 2021
1 parent fd3cb31 commit 7a5a0c6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions samples/snippets/create_http_task_with_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def create_http_task(
location,
url,
service_account_email,
audience=None,
payload=None,
):
# [START cloud_tasks_create_http_task_with_token]
Expand All @@ -35,7 +36,8 @@ def create_http_task(
# project = 'my-project-id'
# queue = 'my-queue'
# location = 'us-central1'
# url = 'https://example.com/task_handler'
# url = 'https://example.com/task_handler?param=value'
# audience = 'https://example.com/task_handler'
# service_account_email = 'service-account@my-project-id.iam.gserviceaccount.com';
# payload = 'hello'

Expand All @@ -47,7 +49,7 @@ def create_http_task(
"http_request": { # Specify the type of request.
"http_method": tasks_v2.HttpMethod.POST,
"url": url, # The full url path that the task will be sent to.
"oidc_token": {"service_account_email": service_account_email},
"oidc_token": {"service_account_email": service_account_email, "audience": audience},
}
}

Expand Down

0 comments on commit 7a5a0c6

Please sign in to comment.