bitly

package
v0.0.0-...-e4d3a07 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Endpoint *oauth2.Endpoint = &oauth2.Endpoint{
	AuthURL:  "https://bitly.com/oauth/authorize",
	TokenURL: "https://api-ssl.bitly.com/oauth/access_token",
}

Functions

func NewCallbackHandler

func NewCallbackHandler(cfg *oauth2.Config, ckCfg *autho.CookieConfig, errHandler, terminalHandler http.Handler) http.Handler

NewCallbackHandler is a helper function that constructs a new callback handler using the default token handler bitly.NewTokenHandler() wrapped arround the default bitly.NewUserHandler().

This method saves allot of boilerplate. For more customisable handlers construct your own callback handler by wrapping your own specific token handler around your own specific user handler.

func NewLoginHandler

func NewLoginHandler(cfg *oauth2.Config, ckCfg *autho.CookieConfig) http.Handler

NewLoginHandler creates a new LoginHandler which is resposible for setting a random value (state) to the state cookie. Afterwards the login handler is also responsible for redirecting the user to the provider for the users grant.

func NewTokenHandler

func NewTokenHandler(cfg *oauth2.Config, ckCfg *autho.CookieConfig, errHandler, callbackHandler http.Handler) http.Handler

NewTokenHandler creates a new TokenHandler which is the first handler in the chain responding to the callback from the provider, it is responsible for parsing the response for auth code and state then comparing the cookie state with the request state. Following the parsing the TokenHandler performs the token exchange and adds the token to the request context, calling on success the UserHandler.

func NewUserHandler

func NewUserHandler(cfg *oauth2.Config, errHandler, terminalHandler http.Handler) http.Handler

Types

type Email

type Email struct {
	Email      string `json:"email"`
	IsPrimary  string `json:"is_primary"`
	IsVerified string `json:"is_verified"`
}

Email represents an email on the users account.

type User

type User struct {
	Login            string   `json:"login"`
	Name             string   `json:"name"`
	IsActive         bool     `json:"is_active"`
	Created          string   `json:"created"`
	Modified         string   `json:"modified"`
	IsSSOUser        bool     `json:"is_sso_user"`
	Emails           []*Email `json:"emails"`
	Is2FAEnabled     bool     `json:"is_2fa_enabled"`
	DefaultGroupGuid string   `json:"default_group_guid"`
}

User represents fields accessible on a bitly account.

https://dev.bitly.com/api-reference/#getUser

Jump to

Keyboard shortcuts

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