func aboutPage(w http.ResponseWriter, r *http.Request) { c := appengine.NewContext(r) fmt.Fprintf(w, "<h1>%v</h1>", appengine.DefaultVersionHostname(c)) token, expire, _ := appengine.AccessToken(c, "test") fmt.Fprintf(w, "<p>AccessToken: %v %v", token, expire) fmt.Fprintf(w, "<p>AppID: %v", appengine.AppID(c)) fmt.Fprintf(w, "<p>FQAppID: %v", c.FullyQualifiedAppID()) fmt.Fprintf(w, "<p>Go version: %v", runtime.Version()) fmt.Fprintf(w, "<p>Datacenter: %v", appengine.Datacenter()) fmt.Fprintf(w, "<p>InstanceID: %v", appengine.InstanceID()) fmt.Fprintf(w, "<p>IsDevAppServer: %v", appengine.IsDevAppServer()) fmt.Fprintf(w, "<p>RequestID: %v", appengine.RequestID(c)) fmt.Fprintf(w, "<p>ServerSoftware: %v", appengine.ServerSoftware()) sa, _ := appengine.ServiceAccount(c) fmt.Fprintf(w, "<p>ServiceAccount: %v", sa) keyname, signed, _ := appengine.SignBytes(c, []byte("test")) fmt.Fprintf(w, "<p>SignBytes: %v %v", keyname, signed) fmt.Fprintf(w, "<p>VersionID: %v", appengine.VersionID(c)) fmt.Fprintf(w, "<p>Request: %v", r) r2 := c.Request() fmt.Fprintf(w, "<p>Context Request type/value: %T %v", r2, r2) }
// Implements the Sign method from SigningMethod // For this signing method, a valid appengine.Context must be // passed as the key. func (s *SigningMethodAppEngine) Sign(signingString string, key interface{}) (string, error) { var ctx appengine.Context switch k := key.(type) { case appengine.Context: ctx = k default: return "", ErrInvalidKey } _, signature, err := appengine.SignBytes(ctx, []byte(signingString)) if err != nil { return "", err } return EncodeSegment(signature), nil }