gologin: github.com/dghubble/gologin/oauth1 Index | Files

package oauth1

import "github.com/dghubble/gologin/oauth1"

Package oauth1 provides handles for OAuth1 login and callback requests.


Package Files

context.go doc.go login.go

func AccessTokenFromContext Uses

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

AccessTokenFromContext returns the access token and secret from the ctx.

func AuthRedirectHandler Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

RequestTokenFromContext returns the request token and secret from the ctx.

func WithAccessToken Uses

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 Uses

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

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

Package oauth1 imports 6 packages (graph) and is imported by 8 packages. Updated 2017-01-11. Refresh now. Tools for package owners.