CodeSampleX

Sample

cloud.google.com/go/auth v0.24.1: StyleInParams

Verified sample for golang cloud.google.com/go/auth v0.24.1: StyleInParams. The contract ran on go 1.26 · linux debian/x64 · docker and passed.

sha256:b732c78bfba2811fca5164bc51f76d6f7049ef154a18b0f10e92aaa5179ec15e

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1

Verification-run environments

Environment Contract Stages Run
go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a…
2026-10-13

Case

HOW
Goal
verify cloud.google.com/go/auth.StyleInParams in pkg:golang/cloud.google.com/go/auth@v0.24.1
Packages
Symbols
  • cloud.google.com/go/auth.StyleInParams
Environment
go 1.26.6
Created
2026-10-13T01:35:20Z

Contract

  1. auth.StyleInParams is an auth.Style constant distinct from StyleUnknown and StyleInHeader
  2. sample.GetStyleInParams and sample.IsStyleInParams identify auth.StyleInParams
  3. sample.New3LOOptions constructs Options3LO with AuthStyle set to StyleInParams
  4. auth.New3LOTokenProvider with StyleInParams sends client credentials in POST body parameters without Authorization header
  5. auth.New3LOTokenProvider with StyleUnknown returns an error during token exchange

Files

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • sample.go
  • spec.json
  • test/contract.go

Download the source artifact (tar.gz)

Source

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify cloud.google.com/go/auth.StyleInParams in pkg:golang/cloud.google.com/go/auth@v0.24.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/cloud.google.com/go/auth@v0.24.1
Demonstrate these symbols/APIs:
  - cloud.google.com/go/auth.StyleInParams

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:32ad3ac434b3b6703ec46ccaad426f84a071999b764b9947b2b25fd8ddc852e7","contract":["auth.StyleInParams is an auth.Style constant distinct from StyleUnknown and StyleInHeader","sample.GetStyleInParams and sample.IsStyleInParams identify auth.StyleInParams","sample.New3LOOptions constructs Options3LO with AuthStyle set to StyleInParams","auth.New3LOTokenProvider with StyleInParams sends client credentials in POST body parameters without Authorization header","auth.New3LOTokenProvider with StyleUnknown returns an error during token exchange"],"goal":"verify cloud.google.com/go/auth.StyleInParams in pkg:golang/cloud.google.com/go/auth@v0.24.1","kind":"HOW","packages":["pkg:golang/cloud.google.com/go/auth@v0.24.1"],"schemaVersion":1,"symbols":["cloud.google.com/go/auth.StyleInParams"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","language":"go","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/cloud.google.com/go/auth@v0.24.1"],"schemaVersion":1,"subject":"pkg:golang/cloud.google.com/go/auth@v0.24.1","symbols":["cloud.google.com/go/auth.StyleInParams"],"verifierAdapter":"golang@1"}
go.mod
module sample

go 1.26.0

require cloud.google.com/go/auth v0.24.1

require (
	cloud.google.com/go/compute/metadata v0.9.0 // indirect
	github.com/googleapis/gax-go/v2 v2.26.2 // indirect
	golang.org/x/sys v0.47.0 // indirect
)
go.sum
cloud.google.com/go/auth v0.24.1 h1:NTmd2iJb4DsGIav0KiqFMYI88nMshA2wnFMBatRmoCs=
cloud.google.com/go/auth v0.24.1/go.mod h1:1dmBXa9xfBvBr39ZnDUDkaaA91ccq9CcqENDgJA4d7c=
cloud.google.com/go/compute/metadata v0.9.0 h1:pDUj4QMoPejqq20dK0Pg2N4yG9zIkYGdBtwLoEkH9Zs=
cloud.google.com/go/compute/metadata v0.9.0/go.mod h1:E0bWwX5wTnLPedCKqk3pJmVgCBSM6qQI1yTBdEb3C10=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/s2a-go v0.1.9 h1:LGD7gtMgezd8a/Xak7mEWL0PjoTQFvpRudN895yqKW0=
github.com/google/s2a-go v0.1.9/go.mod h1:YA0Ei2ZQL3acow2O62kdp9UlnvMmU7kA6Eutn0dXayM=
github.com/googleapis/enterprise-certificate-proxy v0.3.17 h1:73NfMHdiqo9JFU9+7a5ExpVa10/R29pXfZIaW559nrg=
github.com/googleapis/enterprise-certificate-proxy v0.3.17/go.mod h1:rSEsBUemEBZEexP2y6jPp16LUmUbjmSbcPMQizR0o4k=
github.com/googleapis/gax-go/v2 v2.26.2 h1:ydkmNXxj7bEmmeK5AihkKnWxyOyBR9TDebvp5L5izk8=
github.com/googleapis/gax-go/v2 v2.26.2/go.mod h1:sMKqnMesnKH+3wiRJROcttA+cJoZoGbZl1vDQ8XYtGk=
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.67.0 h1:OyrsyzuttWTSur2qN/Lm0m2a8yqyIjUVBZcxFPuXq2o=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.67.0/go.mod h1:C2NGBr+kAB4bk3xtMXfZ94gqFDtg/GkI7e9zqGh5Beg=
go.opentelemetry.io/otel v1.45.0 h1:pdrWmLHofpubmArBv1LgFSv1Z0Ie/ppdZzu+kUN5EeU=
go.opentelemetry.io/otel v1.45.0/go.mod h1:XZxIqPapzEYnhNSScF5DIqXhm/rYi0FzCe2XddAwZfQ=
go.opentelemetry.io/otel/metric v1.45.0 h1:7Eg1uH7CJ5cXv9is6tnBe1FI6rj1nwUdbFypRm3br/M=
go.opentelemetry.io/otel/metric v1.45.0/go.mod h1:HAPbm1nd3p1PmFH7v2dR+6BjXxw+Lq4a2+pndMAm08s=
go.opentelemetry.io/otel/trace v1.45.0 h1:l/mP6Uv7oNO7/TblbhpbgMidxhq1uO/rPsikOyVhxag=
go.opentelemetry.io/otel/trace v1.45.0/go.mod h1:qoJJA2xNMnxRrdISU/kLtfUH2wNeQbiv+jhs/CxI8bc=
golang.org/x/crypto v0.55.0 h1:+KWHjbgOaAQ66dh/YlkZKHlz9ZUlq61AFirAR9ntP8M=
golang.org/x/crypto v0.55.0/go.mod h1:uq0V9dE/fzQuJtbnL+2EhWOE63vo164FY8xqEnV9xis=
golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To=
golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU=
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8=
golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M=
google.golang.org/api v0.288.0 h1:glhO/J88obKP5I269W3hB73dvBKrjU56ZfmNlNXpgTU=
google.golang.org/api v0.288.0/go.mod h1:lM2kYRzYUCBY91P9h6VF1PYmvhxii3O5hji37qRvIcY=
google.golang.org/genproto v0.0.0-20260715232425-e75dac1f907d h1:C9v1o0/4quuhOAfmRXA2j+we0PqZIp8traLdeogF3Ms=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260715232425-e75dac1f907d h1:Jkpk39hlTZOIp3RbfvNX9R8Hv+Sw0X89nlU/xFOErsc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260715232425-e75dac1f907d/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
google.golang.org/grpc v1.83.2 h1:EManeRomTObA0BU7I8vXgg/78uE5MJ9M8B39EX2WscU=
google.golang.org/grpc v1.83.2/go.mod h1:YPI1hK3kDked6iHvgX3tR0y+nX/qpMFKhPgFsokw1S8=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
sample.go
package sample

import (
	"cloud.google.com/go/auth"
)

// GetStyleInParams returns the StyleInParams constant from cloud.google.com/go/auth.
func GetStyleInParams() auth.Style {
	return auth.StyleInParams
}

// IsStyleInParams reports whether the given Style is StyleInParams.
func IsStyleInParams(s auth.Style) bool {
	return s == auth.StyleInParams
}

// New3LOOptions creates an Options3LO configured with the specified parameters and auth style.
func New3LOOptions(clientID, clientSecret, authURL, tokenURL, refreshToken string, style auth.Style) *auth.Options3LO {
	return &auth.Options3LO{
		ClientID:     clientID,
		ClientSecret: clientSecret,
		AuthURL:      authURL,
		TokenURL:     tokenURL,
		AuthStyle:    style,
		RefreshToken: refreshToken,
	}
}

// Create3LOTokenProvider initializes a TokenProvider with the provided 3LO options.
func Create3LOTokenProvider(opts *auth.Options3LO) (auth.TokenProvider, error) {
	return auth.New3LOTokenProvider(opts)
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify cloud.google.com/go/auth.StyleInParams in pkg:golang/cloud.google.com/go/auth@v0.24.1",
  "kind": "HOW",
  "packages": [
    "pkg:golang/cloud.google.com/go/auth@v0.24.1"
  ],
  "symbols": [
    "cloud.google.com/go/auth.StyleInParams"
  ]
}
test/contract.go
package main

import (
	"context"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
	"net/http/httptest"
	"net/url"
	"os"
	"strings"

	"cloud.google.com/go/auth"
	"sample"
)

func main() {
	if err := runContractTests(); err != nil {
		fmt.Fprintf(os.Stderr, "Contract test failed: %v\n", err)
		os.Exit(1)
	}
	fmt.Println("All StyleInParams contract assertions passed.")
}

func runContractTests() error {
	ctx := context.Background()

	// 1. Verify constant value and type
	if auth.StyleInParams != 1 {
		return fmt.Errorf("expected StyleInParams to be 1, got %d", auth.StyleInParams)
	}
	if auth.StyleUnknown != 0 {
		return fmt.Errorf("expected StyleUnknown to be 0, got %d", auth.StyleUnknown)
	}
	if auth.StyleInHeader != 2 {
		return fmt.Errorf("expected StyleInHeader to be 2, got %d", auth.StyleInHeader)
	}

	// 2. Verify sample helper functions
	if sample.GetStyleInParams() != auth.StyleInParams {
		return fmt.Errorf("expected sample.GetStyleInParams() to return auth.StyleInParams")
	}
	if !sample.IsStyleInParams(auth.StyleInParams) {
		return fmt.Errorf("expected sample.IsStyleInParams(auth.StyleInParams) to be true")
	}
	if sample.IsStyleInParams(auth.StyleInHeader) {
		return fmt.Errorf("expected sample.IsStyleInParams(auth.StyleInHeader) to be false")
	}

	// 3. Test offline 3LO token provider with StyleInParams
	var receivedBody url.Values
	var receivedAuthHeader string
	var receivedContentType string

	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		receivedAuthHeader = r.Header.Get("Authorization")
		receivedContentType = r.Header.Get("Content-Type")
		bodyBytes, err := io.ReadAll(r.Body)
		if err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}
		vals, err := url.ParseQuery(string(bodyBytes))
		if err != nil {
			http.Error(w, err.Error(), http.StatusBadRequest)
			return
		}
		receivedBody = vals

		w.Header().Set("Content-Type", "application/json")
		_ = json.NewEncoder(w).Encode(map[string]interface{}{
			"access_token": "mock-access-token-params-auth",
			"token_type":   "Bearer",
			"expires_in":   3600,
		})
	}))
	defer ts.Close()

	opts := sample.New3LOOptions(
		"test-client-id-123",
		"test-client-secret-456",
		ts.URL+"/auth",
		ts.URL+"/token",
		"mock-refresh-token-789",
		auth.StyleInParams,
	)
	opts.Client = ts.Client()

	tp, err := sample.Create3LOTokenProvider(opts)
	if err != nil {
		return fmt.Errorf("failed to create 3LO token provider: %w", err)
	}

	tok, err := tp.Token(ctx)
	if err != nil {
		return fmt.Errorf("token retrieval failed: %w", err)
	}
	if tok == nil || tok.Value != "mock-access-token-params-auth" {
		return fmt.Errorf("unexpected token value: %v", tok)
	}

	// Verify that credentials were sent in POST body parameters, not in Authorization header
	if receivedAuthHeader != "" {
		return fmt.Errorf("expected empty Authorization header with StyleInParams, got: %s", receivedAuthHeader)
	}
	if receivedBody.Get("client_id") != "test-client-id-123" {
		return fmt.Errorf("expected client_id in body, got: %s", receivedBody.Get("client_id"))
	}
	if receivedBody.Get("client_secret") != "test-client-secret-456" {
		return fmt.Errorf("expected client_secret in body, got: %s", receivedBody.Get("client_secret"))
	}
	if !strings.Contains(receivedContentType, "application/x-www-form-urlencoded") {
		return fmt.Errorf("expected form urlencoded content type, got: %s", receivedContentType)
	}

	// 4. Test offline 3LO token provider with StyleUnknown fails or rejects
	optsUnknown := sample.New3LOOptions(
		"test-client-id-123",
		"test-client-secret-456",
		ts.URL+"/auth",
		ts.URL+"/token",
		"mock-refresh-token-789",
		auth.StyleUnknown,
	)
	optsUnknown.Client = ts.Client()
	tpUnknown, err := sample.Create3LOTokenProvider(optsUnknown)
	if err == nil {
		_, errUnknown := tpUnknown.Token(ctx)
		if errUnknown == nil {
			return fmt.Errorf("expected error when using StyleUnknown")
		}
	}

	return nil
}

Origin Seeder

anonymous