|
30 | 30 | OAUTH_TOKEN_URI = 'https://www.googleapis.com/oauth2/v4/token' |
31 | 31 |
|
32 | 32 |
|
33 | | -def make_iap_request(url, client_id): |
| 33 | +def make_iap_request(url, client_id, method='GET', **kwargs): |
34 | 34 | """Makes a request to an application protected by Identity-Aware Proxy. |
35 | 35 |
|
36 | 36 | Args: |
37 | 37 | url: The Identity-Aware Proxy-protected URL to fetch. |
38 | 38 | 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 |
39 | 43 |
|
40 | 44 | Returns: |
41 | 45 | 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): |
94 | 98 | # Fetch the Identity-Aware Proxy-protected URL, including an |
95 | 99 | # Authorization header containing "Bearer " followed by a |
96 | 100 | # Google-issued OpenID Connect token for the service account. |
97 | | - resp = requests.get( |
98 | | - url, |
| 101 | + resp = requests.request( |
| 102 | + method, url, |
99 | 103 | headers={'Authorization': 'Bearer {}'.format( |
100 | | - google_open_id_connect_token)}) |
| 104 | + google_open_id_connect_token)}, **kwargs) |
101 | 105 | if resp.status_code == 403: |
102 | 106 | raise Exception('Service account {} does not have permission to ' |
103 | 107 | 'access the IAP-protected application.'.format( |
|
0 commit comments