forked from Mirrors/oauth2
google/appengine: change managed VMs context to context.Context
This follows the change to the google.golang.org/appengine packages to use the standard context.Context type throughout. Change-Id: I91b456105ee29f2088c3646145ea0a940f8ffaf4 Reviewed-on: https://go-review.googlesource.com/3172 Reviewed-by: Burcu Dogan <jbd@google.com> Reviewed-by: David Symonds <dsymonds@golang.org>
This commit is contained in:
parent
267028f9bc
commit
d8ba9d6c17
|
@ -19,7 +19,7 @@ import (
|
|||
// If you are implementing a 3-legged OAuth 2.0 flow on App Engine
|
||||
// that involves user accounts, see oauth2.Config instead.
|
||||
//
|
||||
// You are required to provide a valid appengine.Context as context.
|
||||
// The provided context must have come from appengine.NewContext.
|
||||
func AppEngineTokenSource(ctx oauth2.Context, scope ...string) oauth2.TokenSource {
|
||||
return &appEngineTokenSource{
|
||||
ctx: ctx,
|
||||
|
|
|
@ -9,6 +9,7 @@ package google
|
|||
import (
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"golang.org/x/oauth2"
|
||||
"google.golang.org/appengine"
|
||||
)
|
||||
|
@ -18,7 +19,7 @@ import (
|
|||
// If you are implementing a 3-legged OAuth 2.0 flow on App Engine
|
||||
// that involves user accounts, see oauth2.Config instead.
|
||||
//
|
||||
// You are required to provide a valid appengine.Context as context.
|
||||
// The provided context must have come from appengine.NewContext.
|
||||
func AppEngineTokenSource(ctx oauth2.Context, scope ...string) oauth2.TokenSource {
|
||||
return &appEngineTokenSource{
|
||||
ctx: ctx,
|
||||
|
@ -28,7 +29,7 @@ func AppEngineTokenSource(ctx oauth2.Context, scope ...string) oauth2.TokenSourc
|
|||
}
|
||||
|
||||
var aeVMFetcherFunc = func(ctx oauth2.Context, scope ...string) (string, time.Time, error) {
|
||||
c, ok := ctx.(appengine.Context)
|
||||
c, ok := ctx.(context.Context)
|
||||
if !ok {
|
||||
return "", time.Time{}, errInvalidContext
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ var (
|
|||
aeTokens = make(map[string]*tokenLock) // key is '\0'-separated scopes
|
||||
)
|
||||
|
||||
var errInvalidContext = errors.New("oauth2: a valid appengine.Context is required")
|
||||
var errInvalidContext = errors.New("oauth2: context must come from appengine.NewContext")
|
||||
|
||||
type tokenLock struct {
|
||||
mu sync.Mutex // guards t; held while updating t
|
||||
|
|
Loading…
Reference in New Issue