The URL is:
http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/
URL: /computeMetadata/v1/instance/service-accounts/default/token
Result: A JSON object containing an access_token you can use in Authorization headers. The URL is:
http://metadata
package mainimport ( "fmt" "io/ioutil" "net/http" )
func main() { url := "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Metadata-Flavor", "Google") client := &http.Client{} resp, _ := client.Do(req) body, _ := ioutil.ReadAll(resp.Body) fmt.Println(string(body)) }All requests to the Compute Engine metadata server
All requests to the Compute Engine metadata server must include the header: _ := http.NewRequest("GET"