Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I access an IAP protected resource using Python?

How can I access an IAP protected resource using Python? More specifically I'd like to generate the Bearer token needed in the Authorization header to make calls to the IAP protected resource.

I have created a service account, given it "IAP-Secured Webapp User" permissions and have downloaded its JSON credentials to disk.

like image 847
Ztyx Avatar asked Aug 16 '26 12:08

Ztyx


1 Answers

Since you have created a service account for authentication, you can use an OIDC token for authentication into IAP-secured resources.

The steps to obtain and use the token for authentication are shown here, but here is a little summary:

  • Head to the Cloud IAP page in the console and edit the OAuth client of the resource you wish to access to.
  • With the client ID you get from the Credentials page, request an OIDC token.
  • Include the OIDC token in the Authorization: Bearer header, and that way you will have an authenticated request to the IAP-protected resource.
like image 98
Rodrigo C. Avatar answered Aug 18 '26 02:08

Rodrigo C.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!