oauth2

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package oauth2 provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.5.0 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRequestTokenRequestWithBody

func NewRequestTokenRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewRequestTokenRequestWithBody generates requests for RequestToken with any type of body

func NewRequestTokenRequestWithFormdataBody

func NewRequestTokenRequestWithFormdataBody(server string, body RequestTokenFormdataRequestBody) (*http.Request, error)

NewRequestTokenRequestWithFormdataBody calls the generic RequestToken builder with application/x-www-form-urlencoded body

Types

type Client

type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example. This can contain a path relative
	// to the server, such as https://api.deepmap.com/dev-test, and all the
	// paths in the swagger spec will be appended to the server.
	Server string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	Client HttpRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn
}

Client which conforms to the OpenAPI3 specification for this service.

func NewClient

func NewClient(server string, opts ...ClientOption) (*Client, error)

Creates a new Client, with reasonable defaults

func (*Client) RequestTokenWithBody

func (c *Client) RequestTokenWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) RequestTokenWithFormdataBody

func (c *Client) RequestTokenWithFormdataBody(ctx context.Context, body RequestTokenFormdataRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

type ClientInterface

type ClientInterface interface {
	// RequestTokenWithBody request with any body
	RequestTokenWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	RequestTokenWithFormdataBody(ctx context.Context, body RequestTokenFormdataRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
}

The interface specification for the client above.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient

func WithHTTPClient(doer HttpRequestDoer) ClientOption

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

func WithRequestEditorFn

func WithRequestEditorFn(fn RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

type ClientWithResponses

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses

func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)

NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling

func (*ClientWithResponses) RequestTokenWithBodyWithResponse

func (c *ClientWithResponses) RequestTokenWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RequestTokenResponse, error)

RequestTokenWithBodyWithResponse request with arbitrary body returning *RequestTokenResponse

func (*ClientWithResponses) RequestTokenWithFormdataBodyWithResponse

func (c *ClientWithResponses) RequestTokenWithFormdataBodyWithResponse(ctx context.Context, body RequestTokenFormdataRequestBody, reqEditors ...RequestEditorFn) (*RequestTokenResponse, error)

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// RequestTokenWithBodyWithResponse request with any body
	RequestTokenWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RequestTokenResponse, error)

	RequestTokenWithFormdataBodyWithResponse(ctx context.Context, body RequestTokenFormdataRequestBody, reqEditors ...RequestEditorFn) (*RequestTokenResponse, error)
}

ClientWithResponsesInterface is the interface specification for the client with responses above.

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer performs HTTP requests.

The standard http.Client implements this interface.

type OAuth2Error

type OAuth2Error struct {
	// Error Error code
	Error OAuth2ErrorError `json:"error"`

	// ErrorDescription Human-readable ASCII text providing additional information
	ErrorDescription *string `json:"error_description,omitempty"`

	// ErrorUri URI identifying a human-readable web page with information about the error
	ErrorUri *string `json:"error_uri,omitempty"`
}

OAuth2Error RFC 6749 Section 5.2 error response

type OAuth2ErrorError

type OAuth2ErrorError string

OAuth2ErrorError Error code

const (
	InvalidClient        OAuth2ErrorError = "invalid_client"
	InvalidGrant         OAuth2ErrorError = "invalid_grant"
	InvalidRequest       OAuth2ErrorError = "invalid_request"
	InvalidScope         OAuth2ErrorError = "invalid_scope"
	UnauthorizedClient   OAuth2ErrorError = "unauthorized_client"
	UnsupportedGrantType OAuth2ErrorError = "unsupported_grant_type"
)

Defines values for OAuth2ErrorError.

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function

type RequestTokenFormdataBody

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

RequestTokenFormdataBody defines parameters for RequestToken.

type RequestTokenFormdataBody0

type RequestTokenFormdataBody0 struct {
	// ClientId OAuth client ID
	ClientId string `json:"client_id"`

	// ClientSecret OAuth client secret
	ClientSecret string `json:"client_secret"`

	// GrantType OAuth 2.0 grant type
	GrantType RequestTokenFormdataBody0GrantType `json:"grant_type"`

	// Scope Optional space-separated list of scopes
	Scope *string `json:"scope,omitempty"`
}

RequestTokenFormdataBody0 defines parameters for RequestToken.

type RequestTokenFormdataBody0GrantType

type RequestTokenFormdataBody0GrantType string

RequestTokenFormdataBody0GrantType defines parameters for RequestToken.

const (
	ClientCredentials RequestTokenFormdataBody0GrantType = "client_credentials"
)

Defines values for RequestTokenFormdataBody0GrantType.

type RequestTokenFormdataBody1

type RequestTokenFormdataBody1 struct {
	// ClientId OAuth client ID (required for public and confidential clients)
	ClientId string `json:"client_id"`

	// ClientSecret OAuth client secret (often required for confidential clients)
	ClientSecret *string `json:"client_secret,omitempty"`

	// Code Authorization code from the /authorize step
	Code string `json:"code"`

	// GrantType OAuth 2.0 grant type
	GrantType RequestTokenFormdataBody1GrantType `json:"grant_type"`

	// RedirectUri Redirect URI used during authorization
	RedirectUri string `json:"redirect_uri"`
}

RequestTokenFormdataBody1 defines parameters for RequestToken.

type RequestTokenFormdataBody1GrantType

type RequestTokenFormdataBody1GrantType string

RequestTokenFormdataBody1GrantType defines parameters for RequestToken.

const (
	AuthorizationCode RequestTokenFormdataBody1GrantType = "authorization_code"
)

Defines values for RequestTokenFormdataBody1GrantType.

type RequestTokenFormdataRequestBody

type RequestTokenFormdataRequestBody RequestTokenFormdataBody

RequestTokenFormdataRequestBody defines body for RequestToken for application/x-www-form-urlencoded ContentType.

type RequestTokenResponse

type RequestTokenResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *struct {
		// AccessToken Access token (often a JWT)
		AccessToken string `json:"access_token"`

		// ExpiresIn Time until expiration in seconds
		ExpiresIn int `json:"expires_in"`

		// IdToken ID token (returned if `openid` scope was requested)
		IdToken *string `json:"id_token,omitempty"`

		// RefreshToken Refresh token (optional)
		RefreshToken *string `json:"refresh_token,omitempty"`

		// Scope Granted scopes
		Scope *string `json:"scope,omitempty"`

		// TokenType Token type, usually "Bearer"
		TokenType string `json:"token_type"`
	}
	JSON400 *OAuth2Error
	JSON401 *OAuth2Error
	JSON403 *OAuth2Error
}

func ParseRequestTokenResponse

func ParseRequestTokenResponse(rsp *http.Response) (*RequestTokenResponse, error)

ParseRequestTokenResponse parses an HTTP response from a RequestTokenWithResponse call

func (RequestTokenResponse) Status

func (r RequestTokenResponse) Status() string

Status returns HTTPResponse.Status

func (RequestTokenResponse) StatusCode

func (r RequestTokenResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

Jump to

Keyboard shortcuts

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