projects by mrjones

An OAuth 1.0 consumer written in go (golang).

This is still a work in progress! It only supports GETs (not POSTs yet), and has limited fault tolerance. To install the latest version:

goinstall github.com/mrjones/oauth

Using it looks something like this:


import (
  "github.com/mrjones/oauth"
)

c := &oauth.Consumer{
  ConsumerKey:    "key",
  ConsumerSecret: "secret",

  RequestTokenUrl:   "https://www.foo.com/GetRequestToken",
  AuthorizeTokenUrl: "https://www.foo.com/AuthorizeToken",
  AccessTokenUrl:    "https://www.foo.com/AccessToken",

  CallbackUrl:      "oob",
  AdditionalParams: map[string]string{"foo": "bar"},
}

utoken, url, _ := c.GetRequestTokenAndUrl()
fmt.Println(c.TokenAuthorizationUrl(utoken))
fmt.Printf("Grant access, and then enter the verification code here: ")

verificationCode := ""
fmt.Scanln(&verificationCode)

atoken, _ := c.AuthorizeToken(token, verificationCode)
response, err := c.Get("https://www.foo.com/app/thing", nil, atoken)


The code itself is at http://www.github.com/mrjones/oauth