How to create JSON Web Token (JWT) to authenticate to Google Cloud using a service account
I'm looking to authenticate API calls to Google Cloud services via a service account and I need to use a JSON Web Token (JWT) for that (here's the documentation website I'm using to do that: Using OAuth 2.0 for Server to Server Applications | Google Identity | Google Developers).
As part of the request, I'm supposed to create a JWT in the format below:
JWT header
[image.png]JWT claim set[image.png]
I replicated the above JWT header and claims in Xano as follows:
Screenshot 1 of 4[image.png]Screenshot 2 of 4
[image.png]
Screenshot 3 of 4[image.png]
Screenshot 4 of 4[image.png]
However, when I make the request to call the access_token API (last function), I get the error message below saying that there's something wrong with my iat and exp values. Basically, I'm supposed to ensure the timestamp is in seconds (instead of the default milliseconds in Xano) and also to ensure that the duration isn't more than 60mins which is why I added 3600 seconds (60mins in seconds) to the 'now' timestamp to get an expiration time no more than an hour from now, and also divided by 1,000 to convert from milliseconds to seconds.
[image.png]
I've tried making the duration < 60mins (e.g. 50mins) but I keep getting the same error message. Can someone help me figure out what I'm doing wrong / what I'm missing?
Thank you,
Ebenezer
Other
11 replies