oauth2

package
v0.0.0-...-edd856d Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2016 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	GITHUB   = "github"
	FACEBOOK = "facebook"
	GOOGLE   = "google"
	SLACK    = "slack"
)

Supported providers

Variables

This section is empty.

Functions

func GetProfileData

func GetProfileData(endpoint, token string) (map[string]interface{}, error)

GetProfileData retrieves profile data using an endpoint and a token string

func NewConfig

func NewConfig(prefix, url string) *xoauth2.Config

NewConfig is a helper function to make an instance of golang.org/x/oauth2.Config. This must need two environment variables having a given prefix. For example, if prefix is `github`, the variables are `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`. Prefix is normalized with strings.ToUpper. If either value is missing, it makes panic. url is a RedirectURL of oauth2.Config

func WithProviders

func WithProviders(p ...Provider)

WithProviders registers available providers.

Types

type Profile

type Profile interface {
	Token() *xoauth2.Token
	Name() string
	Nickname() string
	AvatarURL() string
}

Profile gives some methods to retrieve major values from profile data.

func ProfileByCode

func ProfileByCode(p Provider, code string) (Profile, error)

ProfileByCode returns a Profile from the given Provider.

type Provider

type Provider interface {
	Name() string
	Config() *xoauth2.Config
	Profile(token *xoauth2.Token) (Profile, error)
}

Provider defines behaviors for oauth2 provider

func ProviderByName

func ProviderByName(name string) Provider

ProviderByName returns a provider given for nnme. This returns nil if there is no registered provider.

func Providers

func Providers() []Provider

Providers return registered providers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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