Documentation ¶
Overview ¶
Package oauth1 provides handles for OAuth1 login and callback requests.
Index ¶
- func AccessTokenFromContext(ctx context.Context) (string, string, error)
- func AuthRedirectHandler(config *oauth1.Config, failure http.Handler) http.Handler
- func CallbackHandler(config *oauth1.Config, success, failure http.Handler) http.Handler
- func CookieTempHandler(config gologin.CookieConfig, success, failure http.Handler) http.Handler
- func EmptyTempHandler(success http.Handler) http.Handler
- func LoginHandler(config *oauth1.Config, success, failure http.Handler) http.Handler
- func RequestTokenFromContext(ctx context.Context) (string, string, error)
- func WithAccessToken(ctx context.Context, accessToken, accessSecret string) context.Context
- func WithRequestToken(ctx context.Context, requestToken, requestSecret string) context.Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccessTokenFromContext ¶
AccessTokenFromContext returns the access token and secret from the ctx.
func AuthRedirectHandler ¶
AuthRedirectHandler reads the request token from the ctx and redirects to the authorization URL.
func CallbackHandler ¶
CallbackHandler handles OAuth1 callback requests by parsing the oauth token and verifier, reading the request token secret from the ctx, then obtaining an access token and adding it to the ctx.
func CookieTempHandler ¶
CookieTempHandler persists or retrieves the request token secret (temporary credentials). If the request token can be read from the ctx (login phase), the secret is set in a short-lived cookie to be read later. Otherwise (callback phase) the cookie is read to retrieve the request token secret and add it to the ctx. If the ctx contains no request token and the request has no temp cookie, the failure handler is called.
Some OAuth1 providers (Twitter, Digits) do NOT require temp secrets to be kept between the login phase and callback phase. To implement those providers, use the EmptyTempHandler instead.
func EmptyTempHandler ¶
EmptyTempHandler adds an empty request token secret to the ctx if none is present to support OAuth1 providers which do not require temp secrets to be kept between the login phase and callback phase.
func LoginHandler ¶
LoginHandler handles OAuth1 login requests by obtaining a request token and secret (temporary credentials) and adding it to the ctx. If successful, handling delegates to the success handler, otherwise to the failure handler.
Typically, the success handler is an AuthRedirectHandler or a handler which stores the request token secret.
func RequestTokenFromContext ¶
RequestTokenFromContext returns the request token and secret from the ctx.
func WithAccessToken ¶
WithAccessToken returns a copy of ctx that stores the access token and secret values.
Types ¶
This section is empty.