oauth1

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package oauth1 provides handles for OAuth1 login and callback requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 ctxh.ContextHandler) ctxh.ContextHandler

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

func CallbackHandler

func CallbackHandler(config *oauth1.Config, success, failure ctxh.ContextHandler) ctxh.ContextHandler

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 ctxh.ContextHandler) ctxh.ContextHandler

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 ctxh.ContextHandler) ctxh.ContextHandler

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 ctxh.ContextHandler) ctxh.ContextHandler

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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