goauth: github.com/alloy-d/goauth Index | Files

package oauth

import "github.com/alloy-d/goauth"

A Go OAuth library, mainly created to interact with Twitter.

Does header-based OAuth over HTTP or HTTPS.

Index

Package Files

error.go helpers.go http.go oauth.go persist.go url.go

Constants

const (
    TempCredentialReq = iota
    OwnerAuthorization
    TokenReq
)

Request types:

const (
    HMAC_SHA1 = "HMAC-SHA1"
)

Supported signature methods:

const OAUTH_VERSION = "1.0"

Supported oauth version (currently the only legal value):

Variables

var None map[string]string

An empty map[string]string. Caters to laziness when no params are given.

func PercentEncode Uses

func PercentEncode(s string) string

Performs percent-encoding as specified by RFC 5849.

Can be reversed with http.URLUnescape.

type OAuth Uses

type OAuth struct {
    ConsumerKey     string
    ConsumerSecret  string
    SignatureMethod string

    Callback string

    RequestTokenURL string
    OwnerAuthURL    string
    AccessTokenURL  string

    AccessToken  string
    AccessSecret string

    // NOT initialized.
    RequestTokenParams map[string]string

    RequestToken  string
    RequestSecret string
    // contains filtered or unexported fields
}

func (*OAuth) AuthorizationURL Uses

func (o *OAuth) AuthorizationURL() (string, error)

The URL the user needs to visit to grant authorization. Call after GetRequestToken().

func (*OAuth) Authorized Uses

func (o *OAuth) Authorized() bool

func (*OAuth) Get Uses

func (o *OAuth) Get(url string, params map[string]string) (r *http.Response, err error)

func (*OAuth) GetAccessToken Uses

func (o *OAuth) GetAccessToken(verifier string) (err error)

Performs the final step in the dance: getting the access token.

Call this after GetRequestToken() and getting user verification.

func (*OAuth) GetRequestToken Uses

func (o *OAuth) GetRequestToken() (err error)

Initiates the OAuth dance.

func (*OAuth) Load Uses

func (o *OAuth) Load(fileName string) (err error)

Loads access token information from a file.

func (*OAuth) Post Uses

func (o *OAuth) Post(url string, params map[string]string) (r *http.Response, err error)

func (*OAuth) Save Uses

func (o *OAuth) Save(fileName string) (err error)

Stores access token information to the given filename.

Format is the same as the return from the server.

func (*OAuth) UserID Uses

func (o *OAuth) UserID() uint

Returns the user id, if any.

Does not return any dance errors, because that would just be obnoxious. Check for authorization with Authorized().

func (*OAuth) UserName Uses

func (o *OAuth) UserName() string

Returns the username, if any.

Does not return any dance errors. Check for authorization with Authorized().

Package oauth imports 17 packages (graph) and is imported by 8 packages. Updated 2016-07-22. Refresh now. Tools for package owners.