💾 Archived View for godocs.io › golang.org › x › oauth2 › clientcredentials captured on 2024-02-05 at 10:30:50. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-12-28)

➡️ Next capture (2024-03-21)

🚧 View Differences

-=-=-=-=-=-=-

package clientcredentials - golang.org/x/oauth2/clientcredentials - godocs.io

import "golang.org/x/oauth2/clientcredentials"

Package clientcredentials implements the OAuth2.0 "client credentials" token flow, also known as the "two-legged OAuth 2.0".

This should be used when the client is acting on its own behalf or when the client is the resource owner. It may also be used when requesting access to protected resources based on an authorization previously arranged with the authorization server.

See https://tools.ietf.org/html/rfc6749#section-4.4

Types

type Config

type Config struct {
	// ClientID is the application's ID.
	ClientID string

	// ClientSecret is the application's secret.
	ClientSecret string

	// TokenURL is the resource server's token endpoint
	// URL. This is a constant specific to each server.
	TokenURL string

	// Scope specifies optional requested permissions.
	Scopes []string

	// EndpointParams specifies additional parameters for requests to the token endpoint.
	EndpointParams url.Values

	// AuthStyle optionally specifies how the endpoint wants the
	// client ID & client secret sent. The zero value means to
	// auto-detect.
	AuthStyle oauth2.AuthStyle
	// contains filtered or unexported fields
}

Config describes a 2-legged OAuth2 flow, with both the client application information and the server's endpoint URLs.

func (*Config) Client

func (c *Config) Client(ctx context.Context) *http.Client

Client returns an HTTP client using the provided token. The token will auto-refresh as necessary.

The provided context optionally controls which HTTP client is returned. See the oauth2.HTTPClient variable.

The returned Client and its Transport should not be modified.

func (*Config) Token

func (c *Config) Token(ctx context.Context) (*oauth2.Token, error)

Token uses client credentials to retrieve a token.

The provided context optionally controls which HTTP client is used. See the oauth2.HTTPClient variable.

func (*Config) TokenSource

func (c *Config) TokenSource(ctx context.Context) oauth2.TokenSource

TokenSource returns a TokenSource that returns t until t expires, automatically refreshing it as necessary using the provided context and the client ID and client secret.

Most users will use Config.Client instead.

Details

Version: v0.16.0 (latest)

Platform: linux/amd64

Imports: 7 packages

Refresh now

Back to home

Search