Version: v2.1.0+incompatible Latest Latest

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

Go to latest
Published: Nov 20, 2018 License: MIT Imports: 6 Imported by: 45



Package oauth1 provides handles for OAuth1 login and callback requests.



This section is empty.


This section is empty.


func AccessTokenFromContext

func AccessTokenFromContext(ctx context.Context) (string, string, error)

AccessTokenFromContext returns the access token and secret from the ctx.

func AuthRedirectHandler

func AuthRedirectHandler(config *oauth1.Config, failure http.Handler) http.Handler

AuthRedirectHandler reads the request token from the ctx and redirects to the authorization URL.

func CallbackHandler

func CallbackHandler(config *oauth1.Config, success, failure http.Handler) http.Handler

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

func CookieTempHandler(config gologin.CookieConfig, success, failure http.Handler) http.Handler

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

func EmptyTempHandler(success http.Handler) http.Handler

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

func LoginHandler(config *oauth1.Config, success, failure http.Handler) http.Handler

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

func RequestTokenFromContext(ctx context.Context) (string, string, error)

RequestTokenFromContext returns the request token and secret from the ctx.

func WithAccessToken

func WithAccessToken(ctx context.Context, accessToken, accessSecret string) context.Context

WithAccessToken returns a copy of ctx that stores the access token and secret values.

func WithRequestToken

func WithRequestToken(ctx context.Context, requestToken, requestSecret string) context.Context

WithRequestToken returns a copy of ctx that stores the request token and secret values.


This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL