func ExampleSigned_multipleClaims() { c := &jwt.Claims{ Subject: "subject", Issuer: "issuer", } c2 := struct { Scopes []string }{ []string{"foo", "bar"}, } raw, err := jwt.Signed(signer).Claims(c).Claims(c2).CompactSerialize() if err != nil { panic(err) } fmt.Println(raw) // Output: eyJhbGciOiJIUzI1NiJ9.eyJTY29wZXMiOlsiZm9vIiwiYmFyIl0sImlzcyI6Imlzc3VlciIsInN1YiI6InN1YmplY3QifQ.esKOIsmwkudr_gnfnB4SngxIr-7pspd5XzG3PImfQ6Y }
func ExampleSigned() { key := []byte("secret") sig, err := jose.NewSigner(jose.SigningKey{Algorithm: jose.HS256, Key: key}, &jose.SignerOptions{}) if err != nil { panic(err) } cl := jwt.Claims{ Subject: "subject", Issuer: "issuer", NotBefore: jwt.NewNumericDate(time.Date(2016, 1, 1, 0, 0, 0, 0, time.UTC)), Audience: jwt.Audience{"leela", "fry"}, } raw, err := jwt.Signed(sig).Claims(cl).CompactSerialize() if err != nil { panic(err) } fmt.Println(raw) // Output: eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOlsibGVlbGEiLCJmcnkiXSwiaXNzIjoiaXNzdWVyIiwibmJmIjoxLjQ1MTYwNjRlKzA5LCJzdWIiOiJzdWJqZWN0In0.uazfxZNgnlLdNDK7JkuYj3LlT4jSyEDG8EWISBPUuME }