spotify_proxyserver

package
v0.0.0-...-40e63e7 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RefreshURL = "/oauth/refresh"
)

Variables

This section is empty.

Functions

func EncodeTokenString

func EncodeTokenString(token *oauth2.Token) (string, error)

func Router

func Router(handler *Handler) chi.Router

Types

type ChiMiddleware

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

ChiMiddleware is a handler that exposes prometheus metrics for the number of requests, the latency and the response size, partitioned by status code, method and HTTP path.

func NewChiMiddleware

func NewChiMiddleware(name string, buckets ...float64) *ChiMiddleware

NewMiddleware returns a new prometheus ChiMiddleware handler.

func (ChiMiddleware) Handler

func (c ChiMiddleware) Handler(next http.Handler) http.Handler

func (ChiMiddleware) Zero

func (c ChiMiddleware) Zero(codes []int, methods []string, paths []string)

type Handler

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

func New

func New(clientID, clientSecret, redirectURL string, frontendRenderer Renderer) *Handler

func (*Handler) RefreshCallback

func (h *Handler) RefreshCallback(w http.ResponseWriter, r *http.Request)

Token refresh helper endpoint. Takes a valid oauth2 token containing an access code and a refresh token, and returns a fresh token in return.

func (*Handler) ServeCallback

func (h *Handler) ServeCallback(w http.ResponseWriter, r *http.Request)

Callback URL of oauth2 client credentials flow. Check the XSRF cookie and exchange the authentication code from the URL with an access token using Spotify's oauth2 API. The token is returned back to the user, for use in the client.

func (*Handler) ServeLogin

func (h *Handler) ServeLogin(w http.ResponseWriter, r *http.Request)

First step of oauth2 client credentials flow. Store a cookie in the user's browser with the XSRF protection token, then redirect to Spotify's authentication URL.

type JSONRenderer

type JSONRenderer struct{}

func (*JSONRenderer) Render

func (r *JSONRenderer) Render(w http.ResponseWriter, code int, err error, token *oauth2.Token)

type Renderer

type Renderer interface {
	Render(w http.ResponseWriter, code int, err error, token *oauth2.Token)
}

type Response

type Response struct {
	Error error  `json:"error,omitempty"`
	Token string `json:"token,omitempty"`
}

type TextRenderer

type TextRenderer struct{}

func (*TextRenderer) Render

func (r *TextRenderer) Render(w http.ResponseWriter, code int, err error, token *oauth2.Token)

Jump to

Keyboard shortcuts

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