• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..27-Aug-2018-

google/H27-Aug-2018-903561

internal/H27-Aug-2018-363252

jws/H27-Aug-2018-183121

jwt/H27-Aug-2018-163108

LICENSEH A D27-Aug-20181.4 KiB2824

README.mdH A D27-Aug-20182.5 KiB7856

oauth2.goH A D27-Aug-201811.3 KiB354178

token.goH A D27-Aug-20184.8 KiB176102

transport.goH A D27-Aug-20183.2 KiB145105

README.md

1# OAuth2 for Go
2
3[![Build Status](https://travis-ci.org/golang/oauth2.svg?branch=master)](https://travis-ci.org/golang/oauth2)
4[![GoDoc](https://godoc.org/golang.org/x/oauth2?status.svg)](https://godoc.org/golang.org/x/oauth2)
5
6oauth2 package contains a client implementation for OAuth 2.0 spec.
7
8## Installation
9
10~~~~
11go get golang.org/x/oauth2
12~~~~
13
14Or you can manually git clone the repository to
15`$(go env GOPATH)/src/golang.org/x/oauth2`.
16
17See godoc for further documentation and examples.
18
19* [godoc.org/golang.org/x/oauth2](http://godoc.org/golang.org/x/oauth2)
20* [godoc.org/golang.org/x/oauth2/google](http://godoc.org/golang.org/x/oauth2/google)
21
22
23## App Engine
24
25In change 96e89be (March 2015), we removed the `oauth2.Context2` type in favor
26of the [`context.Context`](https://golang.org/x/net/context#Context) type from
27the `golang.org/x/net/context` package
28
29This means it's no longer possible to use the "Classic App Engine"
30`appengine.Context` type with the `oauth2` package. (You're using
31Classic App Engine if you import the package `"appengine"`.)
32
33To work around this, you may use the new `"google.golang.org/appengine"`
34package. This package has almost the same API as the `"appengine"` package,
35but it can be fetched with `go get` and used on "Managed VMs" and well as
36Classic App Engine.
37
38See the [new `appengine` package's readme](https://github.com/golang/appengine#updating-a-go-app-engine-app)
39for information on updating your app.
40
41If you don't want to update your entire app to use the new App Engine packages,
42you may use both sets of packages in parallel, using only the new packages
43with the `oauth2` package.
44
45```go
46import (
47	"golang.org/x/net/context"
48	"golang.org/x/oauth2"
49	"golang.org/x/oauth2/google"
50	newappengine "google.golang.org/appengine"
51	newurlfetch "google.golang.org/appengine/urlfetch"
52
53	"appengine"
54)
55
56func handler(w http.ResponseWriter, r *http.Request) {
57	var c appengine.Context = appengine.NewContext(r)
58	c.Infof("Logging a message with the old package")
59
60	var ctx context.Context = newappengine.NewContext(r)
61	client := &http.Client{
62		Transport: &oauth2.Transport{
63			Source: google.AppEngineTokenSource(ctx, "scope"),
64			Base:   &newurlfetch.Transport{Context: ctx},
65		},
66	}
67	client.Get("...")
68}
69```
70
71## Report Issues / Send Patches
72
73This repository uses Gerrit for code changes. To learn how to submit changes to
74this repository, see https://golang.org/doc/contribute.html.
75
76The main issue tracker for the oauth2 repository is located at
77https://github.com/golang/oauth2/issues.
78