Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5e958b5

Browse filesBrowse files
danieldeleoandrewsg
authored andcommitted
Adding ability to make reqeusts of all method types: GET, POST, PUT etc (GoogleCloudPlatform#1481)
1 parent 87af05c commit 5e958b5
Copy full SHA for 5e958b5

File tree

Expand file treeCollapse file tree

1 file changed

+8
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-4
lines changed

‎iap/make_iap_request.py

Copy file name to clipboardExpand all lines: iap/make_iap_request.py
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,16 @@
3030
OAUTH_TOKEN_URI = 'https://www.googleapis.com/oauth2/v4/token'
3131

3232

33-
def make_iap_request(url, client_id):
33+
def make_iap_request(url, client_id, method='GET', **kwargs):
3434
"""Makes a request to an application protected by Identity-Aware Proxy.
3535
3636
Args:
3737
url: The Identity-Aware Proxy-protected URL to fetch.
3838
client_id: The client ID used by Identity-Aware Proxy.
39+
method: The request method to use
40+
('GET', 'OPTIONS', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE')
41+
**kwargs: Any of the parameters defined for the request function:
42+
https://github.com/requests/requests/blob/master/requests/api.py
3943
4044
Returns:
4145
The page body, or raises an exception if the page couldn't be retrieved.
@@ -94,10 +98,10 @@ def make_iap_request(url, client_id):
9498
# Fetch the Identity-Aware Proxy-protected URL, including an
9599
# Authorization header containing "Bearer " followed by a
96100
# Google-issued OpenID Connect token for the service account.
97-
resp = requests.get(
98-
url,
101+
resp = requests.request(
102+
method, url,
99103
headers={'Authorization': 'Bearer {}'.format(
100-
google_open_id_connect_token)})
104+
google_open_id_connect_token)}, **kwargs)
101105
if resp.status_code == 403:
102106
raise Exception('Service account {} does not have permission to '
103107
'access the IAP-protected application.'.format(

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.