Skip to content
This repository has been archived by the owner on May 12, 2020. It is now read-only.

Latest commit

 

History

History
32 lines (29 loc) · 1.25 KB

README.md

File metadata and controls

32 lines (29 loc) · 1.25 KB

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}}
	...
}