Google Authorization for Cloud Google Translate

I need help with authorization in Coud Google Translate using the fetch/getJSON method.

curl -X POST \
    -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
    -H "Content-Type: application/json; charset=utf-8" \
    -d @request.json \
    "https://translation.googleapis.com/language/translate/v2"

Documentation: Guia de início rápido: traduzir textos com o Cloud Translation Basic  |  Google Cloud

Variant with API KEY:

curl -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "X-goog-api-key: API_KEY" \
    -H "Content-Type: application/json; charset=utf-8" \
    -d @request.json \
    "https://translation.googleapis.com/language/translate/v2"

Documentation: Autenticar usando chaves de API  |  Autenticação  |  Google Cloud

Use API KEY without having to log in before using the service. How to authorize and write the fetch/getJSON header? (I know how to convert curl to fetch/getJSON.)

Thank you for the advice! :wink: