1

We are using Identity-Aware Proxy to secure our backend which is a REST API. For human users with a google account this works well so far.

I'm currently trying to connect another component to this API which is authenticating using a service account. Unfortunately the documentation on this use case is a little bit sparse. I tried to adapt the example to the client ID of the OAuth client for this IAP.

def prepare_headers():
    open_id_connect_token = id_token.fetch_id_token(Request(), settings.backend.client_id)

    return {
        'Authorization': f'Bearer {open_id_connect_token}'
    }

A service account key file is provided to the program using the GOOGLE_APPLICATION_CREDENTIALS environment variable. Does anybody know how to obtain a working token using python?

2
  • Have you checked examples provided at the documentation here and here? Mar 12, 2021 at 17:43
  • Does open_id_connect_token actually contain an Identity Token (which is a base64 encoded JWT)? A common problem is that you must call a "refresh" method to actually get the token. Your code fragment is too small to know which libraries you are using. Create a minimum complete example. Mar 12, 2021 at 19:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.