Skip to content

Instantly share code, notes, and snippets.

View tw-hotelplan's full-sized avatar
🚀

Tim tw-hotelplan

🚀
  • Hotelplan
  • Zurich
View GitHub Profile
@tw-hotelplan
tw-hotelplan / README.md
Created November 16, 2021 19:36 — forked from ryu1kn/README.md
Getting GCP access token from a service account key JSON file

Getting GCP access token from a service account key

Use your service account's key JSON file to get an access token to call Google APIs.

Good for seeing how things work, including the creation of JWT token.

To create a JWT token, you can replace create-jwt-token.sh script with tools like step.

If you just want to get an access token for a service account,

@tw-hotelplan
tw-hotelplan / readme.md
Created October 18, 2021 14:46 — forked from thomasdarimont/readme.md
Example for decoding a JWT Payload with your Shell (bash, zsh...)

Setup

Add this to your .profile, .bashrc, .zshrc...

decode_base64_url() {
  local len=$((${#1} % 4))
  local result="$1"
  if [ $len -eq 2 ]; then result="$1"'=='
  elif [ $len -eq 3 ]; then result="$1"'=' 
  fi
 echo "$result" | tr '_-' '/+' | openssl enc -d -base64