// Copyright (c) 2026 Probo Inc . // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all copies. // // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY // AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR // OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. package oauth2 import ( "context" "go.probo.inc/probo/pkg/coredata" ) type contextKey struct{ name string } var ( accessTokenContextKey = &contextKey{name: "oauth2_access_token"} clientContextKey = &contextKey{name: "oauth2_client"} ) func ContextWithAccessToken(ctx context.Context, accessToken *coredata.OAuth2AccessToken) context.Context { return context.WithValue(ctx, accessTokenContextKey, accessToken) } func AccessTokenFromContext(ctx context.Context) (*coredata.OAuth2AccessToken, bool) { accessToken, ok := ctx.Value(accessTokenContextKey).(*coredata.OAuth2AccessToken) return accessToken, ok } func ContextWithClient(ctx context.Context, client *coredata.OAuth2Client) context.Context { return context.WithValue(ctx, clientContextKey, client) } func ClientFromContext(ctx context.Context) (*coredata.OAuth2Client, bool) { client, ok := ctx.Value(clientContextKey).(*coredata.OAuth2Client) return client, ok }