oauth

package
v0.0.0-...-2f6044c Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorResponse

type ErrorResponse struct {
	Error       string `json:"error"`
	Description string `json:"error_description"`
}

type HttpClientFactory

type HttpClientFactory func() *http.Client

type OauthClient

type OauthClient struct {
	Service      string
	Client       *http.Client
	Headers      map[string]string
	ClientID     string
	ClientSecret string
	SourceHeader string
}

OauthClient represents a stateful Oauth client

func GetNewClient

func GetNewClient(service string, httpFactory HttpClientFactory) (*OauthClient, error)

GetNewClient creates a new client for the specified endpoint

func GetNewConfidentialClient

func GetNewConfidentialClient(service string, clientID string, clientSecret string, httpFactory HttpClientFactory) (*OauthClient, error)

GetNewConfidentialClient creates a new client for the specified endpoint

func (*OauthClient) AuthorizationCode

func (c *OauthClient) AuthorizationCode(appID string, code_verifier string, code string, redirect_uri string, client_id string) (*TokenResponse, *ErrorResponse, error)

func (*OauthClient) ClientCredentials

func (c *OauthClient) ClientCredentials(appID string, scope string) (*TokenResponse, *ErrorResponse, error)

func (*OauthClient) RefreshToken

func (c *OauthClient) RefreshToken(appID string, refreshToken string) (*TokenResponse, *ErrorResponse, error)

func (*OauthClient) ResourceOwner

func (c *OauthClient) ResourceOwner(appID string, scope string, owner string, ownerPassword string) (*TokenResponse, *ErrorResponse, error)

ResourceOwner implements the ResourceOwner flow

type TokenResponse

type TokenResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
}

TokenResponse represents successful token response

Jump to

Keyboard shortcuts

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