oauthv2

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizationCode

type AuthorizationCode string

type OAuthClient

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

func NewOAuthClient

func NewOAuthClient(restClient rest.Requester) *OAuthClient

func (*OAuthClient) Authenticate

func (o *OAuthClient) Authenticate(p OAuthParams) (OAuthToken, error)

NOTE Rather than returning a pointer set to nil, Use comma ok idiom return a boolean and a value type

func (*OAuthClient) RefreshToken

func (o *OAuthClient) RefreshToken(p OAuthParams, refreshToken string) (OAuthToken, error)

type OAuthParams

type OAuthParams struct {
	ClientId      string
	RedirectUri   string
	Scope         []string
	OAuthEndpoint string
	State         string
}

type OAuthToken

type OAuthToken struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	Scope        string `json:"scope"`
	ExpiresIn    int    `json:"expires_in"`
	//will be used when saving the token on local storage
	ExpiresAt time.Time `json:"expires_at"`
}

func (*OAuthToken) IsExpired

func (t *OAuthToken) IsExpired() bool

NOTE Go uses parameters of pointer type to indicate that a parameter might be modified by the function. The same rules apply for method receivers, too.

--> If your method modifies the receiver, you must use a pointer receiver --> If your method needs to handle nil instances, then it must use a pointer receiver --> If your method doesn't modify the receiver you can use a value receiver.

notice that if we had used a value receiver, there wouldn't be a way to mutate the receiver... however, we don't need to modify the receiver within this method.

Jump to

Keyboard shortcuts

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