1.I'm try to use google translation api V3beta1 to translate words, I use http post to send request, but how to get bearer token by golang? 2.Or if I use grpc protocol, whether can I don't pass the bearer token. and where can I get the v3beta1 grpc interface file.
I test translate v2 rest api, it's ok whitout bearer token,but it return 401 code when I use v3beta1 api, I notice there is a bearer token need to pass, but I don't how to get it with golang.
//code such here
headMap := &http.Header{}
headMap.Add("Content-Type", "application/json")
headMap.Add("Accept", "application/json")
//headMap.Add("Authorization", "Bearer (how to get this bear)")
bodyParams := goov3Req{
Content: "你好",
SourceLanguageCode:"zh",
TargetLanguageCode:"en",
//MimeType:"text",
Model:"nmt",
//Key:googleRestFulKey,
}
fmt.Println(bodyParams)
str, _ := json.Marshal(bodyParams)
var b []byte
var e error
_, b, _, e = util.DoPost("google_its", googleRestFulUrl, *headMap, []byte(str), timeout)
"error": {
----------
//get error code
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}