Skip to content

The oauth package is a simple wrapper around the egothic package and provides a few syntactic niceties.

License

Notifications You must be signed in to change notification settings

agentstation/oauth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

                          ___   __ _  _   _  _    _     
                         / _ \ / _` || | | || |_ | |__  
                        | (_) | (_| || |_| || __|| '_ \ 
                         \___/ \__,_| \__,_| \__||_| |_|

oauth

import "github.com/agentstation/oauth"

Index

Variables

var (
    // GetState gets the state from the oauth session.
    GetState = egothic.GetState
    // SetState sets the state in the oauth session.
    SetState = egothic.SetState
    // GetProviderName gets the provider name from the oauth session.
    GetProviderName = egothic.GetProviderName
)

func Begin

func Begin(e echo.Context) error

Begin starts the authentication process for a given provider.

func GetSession(e echo.Context, key string) (string, error)

GetSession retrieves a value from the session by key. It returns an error if the key doesn't exist.

func Logout

func Logout(e echo.Context) error

Logout invalidates a user session.

func ProviderURL(e echo.Context) (string, error)

ProviderURL returns the authentication URL for the specified provider.

func SetProviders(providers ...goth.Provider)

SetProviders sets the goth oauth providers.

You can find the list of supported providers here: https://github.com/markbates/goth?tab=readme-ov-file#supported-providers

func SetSession(e echo.Context, key string, value string) error

SetSession stores a key/value pair in the session.

func SetStore(store sessions.Store)

SetStore sets the store for the oauth session.

func Store

func Store() sessions.Store

Store returns the store for the oauth session.

type User

User represents an oauth user that has authenticated.

type User struct {
    RawData           map[string]interface{}
    Provider          string
    Email             string
    Name              string
    FirstName         string
    LastName          string
    NickName          string
    Description       string
    UserID            string
    AvatarURL         string
    Location          string
    AccessToken       string
    AccessTokenSecret string
    RefreshToken      string
    ExpiresAt         time.Time
    IDToken           string
}

func Complete(e echo.Context) (User, error)

Complete completes the authentication process and returns the user.

func (*User) Validate

func (u *User) Validate() error

Validate validates the user

Generated by gomarkdoc

About

The oauth package is a simple wrapper around the egothic package and provides a few syntactic niceties.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages