oauth

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 5 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 interface {

	// Create oauth credentials to operate on behalf of a seller
	// It is a post request to the endpoint: "https://api.mercadopago.com/oauth/token"
	// Reference: https://www.mercadopago.com/developers/en/reference/oauth/_oauth_token/post
	Create(ctx context.Context, authorizationCode, redirectURI string) (*Response, error)

	// GetAuthorizationURL gets url for oauth authorization.
	GetAuthorizationURL(clientID, redirectURI, state string) string

	// Refresh token received when you create credentials.
	// It is a post request to the endpoint: "https://api.mercadopago.com/oauth/token"
	// Reference: https://www.mercadopago.com/developers/en/reference/oauth/_oauth_token/post
	Refresh(ctx context.Context, refreshToken string) (*Response, error)
}

Client contains the method to interact with the Oauth API.

func NewClient

func NewClient(c *config.Config) Client

NewClient returns a new Oauth API Client.

type RefreshTokenRequest

type RefreshTokenRequest struct {
	GrantType    string `json:"grant_type,omitempty"`
	ClientSecret string `json:"client_secret,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
}

RefreshTokenRequest represents credential information to perform a refresh credential request.

type Request

type Request struct {
	GrantType    string `json:"grant_type,omitempty"`
	ClientSecret string `json:"client_secret,omitempty"`
	Code         string `json:"code,omitempty"`
	RedirectURI  string `json:"redirect_uri,omitempty"`
}

Request represents credential information to perform a create credential request.

type Response

type Response struct {
	AccessToken  string `json:"access_token"`
	Scope        string `json:"scope"`
	RefreshToken string `json:"refresh_token"`
	PublicKey    string `json:"public_key"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	LiveMode     bool   `json:"live_mode"`
}

Response represents credential information for an Oauth authorization

Jump to

Keyboard shortcuts

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