Fork of the goauth2 project, allowing the library to be used in Google App Engine hosted projects
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/codereview
oauth
AUTHORS
CONTRIBUTORS
LICENSE
PATENTS
README.md

README.md

goauth2

Fork of the goauth2 project, allowing the library to be used in Google App Engine hosted projects (as I do for autosite-go)

Install

Just check out or download the source code from its GitHub repository and copy it to your project's root directory. Import in your GO code like you would any other library:

import (
    "appengine"
    "appengine/urlfetch"
    "github.com/paceline/goauth2/oauth"
    ...
)

Usage

For the most part things work just like shown it the examples here or here. However you need to supply urlfetch.Transport manually, e.g.:

func(w http.ResponseWriter, r *http.Request) {
    c = appengine.NewContext(r)
    config := &oauth.Config{
        ClientId:     *clientId,
        ClientSecret: *clientSecret,
        Scope:        *apiURL,
        AuthURL:      "https://accounts.google.com/o/oauth2/auth",
        TokenURL:     "https://accounts.google.com/o/oauth2/token",
        TokenCache:   oauth.CacheFile(*cachefile),
	}
	transport := &oauth.Transport{Config: config, Transport: &urlfetch.Transport{Context: c}}
	...
}