Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A Go library for doing header-based OAuth over HTTP or HTTPS.
Go
branch: master

Merge pull request #6 from DDRBoxman/gobencode

Export temporary token fields so that OAuth can be encoded with gob
latest commit 905931d281
@alloy-d authored
Failed to load latest commit information.
.hgignore
LICENSE
Makefile
README.markdown
error.go Updates for go weekly.2011-12-22 11100
helpers.go
http.go
oauth.go Export temporary token fields so that OAuth can be encoded with gob
persist.go
url.go

README.markdown

Installation

goinstall github.com/alloy-d/goauth

Usage

import (
    "github.com/alloy-d/goauth"
    "os"
)

func someFuncThatDoesStuffWithOAuth() (err os.Error) {
    o := new (oauth.OAuth)
    o.ConsumerKey = "key"
    o.ConsumerSecret = "secret"
    o.Callback = "callback"

    o.RequestTokenURL = "https://api.twitter.com/oauth/request_token"
    o.OwnerAuthURL = "https://api.twitter.com/oauth/authorize"
    o.AccessTokenURL = "https://api.twitter.com/oauth/access_token"

    err = o.GetRequestToken()
    if err != nil { return }

    url, err := o.AuthorizationURL()
    if err != nil { return }

    // somehow send user to url...

    var verifier string
    // somehow get verifier (or "PIN")...

    err = o.GetAccessToken(verifier)
    if err != nil { return }

    err = o.Save(os.Getenv("HOME") + "/.simple_example.oauth")

    response, err := o.Post(
        "https://api.twitter.com/1/statuses/update.json",
        map[string]string{"status": "Just did a little OAuth dance!"})
    if err != nil { return }

    // do stuff with response...

    return nil
}

Status

This is still a bit of a work in progress. The interface is subject to change (and become prettier), but I think it's mostly done.

It is probably obvious that it's rough around the edges in spots. Please let me know if anything's broken.

Something went wrong with that request. Please try again.