auth

package
v0.0.0-...-789275d Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

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

Auth defines a structure which allows us properly retrieve oauth athentication data from the OAuth2 api.

func New

func New(cred Credential, endpoints oauth2.Endpoint, redirectURL string) *Auth

New returns a new instance of OAuth.

func (*Auth) AuthorizeFromUser

func (a *Auth) AuthorizeFromUser(code string) (*http.Client, Token, error)

AuthorizeFromUser takes the code retrieved from the users login process and attempts to retrieve a access token from the configuration.

func (*Auth) LoginURL

func (a *Auth) LoginURL(state string, xs ...oauth2.AuthCodeOption) string

LoginURL returns the login URL for redirect users to login into acct to provide access token for API requests.

type Credential

type Credential struct {
	ClientID     string   `json:"client_id"`
	ClientSecret string   `json:"client_secret"`
	Scopes       []string `json:"scopes"`
}

Credential defines a struct which holds clientID and clientSecret which are used by oauths.

type Token

type Token struct {
	Type        string    `json:"type"`
	AccessToken string    `json:"access_token"`
	Expires     time.Time `json:"expires"`
}

Token defines the data returned from a OAuth op.

func (Token) Fields

func (t Token) Fields() map[string]interface{}

Fields returns the given fields as a map.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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