authentication - How to get id tokens from OICD-authenticated servers? - Stack Overflow

I am trying to connect to my Cloud run backend from the vercel frontend (not client side).I have setup

I am trying to connect to my Cloud run backend from the vercel frontend (not client side).

I have setup the workload federated identity, and the connection appears to work correctly if I run the following:

    authClient = ExternalAccountClient.fromJSON({
      type: "external_account",
      audience: `//iam.googleapis/projects/${GCP_PROJECT_NUMBER}/locations/global/workloadIdentityPools/${GCP_WORKLOAD_IDENTITY_POOL_ID}/providers/${GCP_WORKLOAD_IDENTITY_POOL_PROVIDER_ID}`,
      subject_token_type: "urn:ietf:params:oauth:token-type:jwt",
      token_url: ";,
      service_account_impersonation_url: `/${GCP_SERVICE_ACCOUNT_EMAIL}:generateAccessToken`,
      subject_token_supplier: {
        // Use the Vercel OIDC token as the subject token.
        getSubjectToken: getVercelOidcToken,
      },
    });

This is fine, however what I really need is the GoogleAuth object, which I can use to get the ID token required to connect to the cloud run backend - something like this:

  const auth = new GoogleAuth({
    scopes: ";,
    projectId: GCP_PROJECT_ID,
  });
const idTokenclient = await auth.getIdTokenClient(backend_url);
const response = await idTokenclient.request({ url: backend_url });

What I don't understand is how to go from the ExternalAccountClient to the GoogleAuth client. Is there a way I can pass the accessToken or some sort of credentials to the GoogleAuth call? (Which I believe right now would just try to reuse the local auth credentials from the machine, which are not available on a serverless environment?)


Edit: Gentle ping :) Would really love an answer here (or some pointers!)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742404564a4437583.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信