You have to do 2 steps specified in here, if you follow correctly you will get this done.
First, (only the first time) you need to set up your project and download the GOOGLE APPLICATION CREDENTIALS
you will result with one json file with auth information inside, lets suppose you call it project.json
Now you will need to execute some commands to get access tokens, download and install Cloud SDK to have access to those commands.
gcloud auth activate-service-account --key-file=/home/panchicore/project.json
then
gcloud auth print-access-token
you will get your key at this point, now we can use it in the next step:
Second, Make a Translation API request: (how I did it and tested with python requests)
import requests
key = "KEY GOT WITH gcloud auth print-access-token"
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer {}'.format(key)
}
url = 'https://translation.googleapis.com/language/translate/v2'
data = {
'q': 'The quick brown fox jumped over the lazy dog.',
'source': 'en',
'target': 'es',
'format': 'text'
}
res = requests.post(url, json=data, headers=headers)
print res.content
>>> El rápido zorro marrón saltó sobre el perro perezoso.
Hope it helps.