Efaz
Efaz

Reputation: 304

Invalid Argument error when calling signJWT

I am following this documentation https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/signJwt to generate a signed JWT

Path Parameter: name: projects/-/serviceAccounts/[email protected]

This is my request body

{
  "delegates": []
  "payload": "{'sub': '[email protected]', 'iat': 1661250118, 'exp': 1661253718, 'aud': 'https://www.googleapis.com/auth/iam'}"
}

I am getting this invalid argument error.

Am I missing something in the payload? enter image description here

I dont think I have any issues with permission as I was able to get success response when I tried generateAccessToken api call

Upvotes: 0

Views: 468

Answers (2)

Just Another Developer
Just Another Developer

Reputation: 518

This worked for me by replacing all single quotes ( ' ) with \" (escaping double quotes)

{ "delegates": [], "payload": "{"sub": "[email protected]", "iat": 1661250118, "exp": 1661253718, "aud": "https://www.googleapis.com/auth/iam"}" }

Upvotes: 0

Gabriel Robledo Ahumada
Gabriel Robledo Ahumada

Reputation: 1701

You are missing a comma after "delegates": [], in the request body. It should follow the structure:

{
  "delegates": [
    string
  ],
  "payload": string
}

Upvotes: 1

Related Questions