accountsv1

package
v0.0.0-...-c49e589 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a wrapper around SAMS primitive REST-based Accounts API. Most likely, you want to use the more service-to-service "Clients" API instead.

This API is needed when using SAMS to identify users, but not perform authorization checks. e.g. the caller will handle its own authorization checks based on the identity of the SAMS user. (The returned User.Sub, the SAMS account external ID.)

func NewClient

func NewClient(samsHost string, tokenSource oauth2.TokenSource) *Client

NewClient constructs a new SAMS Accounts client, pointed to the supplied SAMS host. e.g. "https://accounts.sourcegraph.com".

Users should prefer to use the top-level 'sams.NewAccountsV1' constructor instead.

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context) (*User, error)

GetUser returns the basic user profile of the calling user. (Who owns the underlying token or TokenSource the client is using for authentication.)

If the supplied token is invalid, malformed, or expired, the error will contain "unexpected status 401".

type Metadata

type Metadata map[string]any

type MetadataSet

type MetadataSet map[string]Metadata

type User

type User struct {
	Sub           string    `json:"sub"`            // OIDC-compliant field name, DO NOT change
	Name          string    `json:"name"`           // OIDC-compliant field name, DO NOT change
	Email         string    `json:"email"`          // OIDC-compliant field name, DO NOT change
	Picture       string    `json:"picture"`        // OIDC-compliant field name, DO NOT change
	EmailVerified bool      `json:"email_verified"` // OIDC-compliant field name, DO NOT change
	CreatedAt     time.Time `json:"created_at"`     // OIDC-compliant field name, DO NOT change

	// Metadata is a map of metadata scope to metadata JSON contents.
	Metadata MetadataSet `json:"metadata,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL