Please see my previous post for more context.
I’m getting the header from Google Cloud Endpoint Service and reading it inside a Go Google Cloud Function.
It looks very strange that I have to add a “}” to make it works!
My commit contains the following code
authuserinfo := string(r.Header.Get("X-Endpoint-Api-Userinfo"))
userinfo, _ := b64.StdEncoding.DecodeString(authuserinfo)
var authperm struct {
Iss string `json:"iss"`
Sub string `json:"sub"`
Aud []string `json:"aud"`
Iat int `json:"iat"`
Exp int `json:"exp"`
Azp string `json:"azp"`
Scope string `json:"scope"`
Permissions []string `json:"permissions"`
}
if permerr := json.Unmarshal([]byte(string(userinfo)+"}"), &authperm); permerr != nil {
switch permerr {
case io.EOF:
fmt.Fprint(w, "no auth permissions")
return
default:
fmt.Fprint(w, permerr.Error() + " from " + string(userinfo) )
return
}
}