Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: impl/prod/context.go

Issue 1632943003: impl/prod: Expose Remote API scopes. (Closed) Base URL: https://github.com/luci/gae@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package prod 5 package prod
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "net/http" 9 "net/http"
10 "net/http/cookiejar" 10 "net/http/cookiejar"
11 "net/url" 11 "net/url"
12 "strings" 12 "strings"
13 13
14 "github.com/luci/gae/service/info" 14 "github.com/luci/gae/service/info"
15 "github.com/luci/gae/service/urlfetch" 15 "github.com/luci/gae/service/urlfetch"
16 "golang.org/x/net/context" 16 "golang.org/x/net/context"
17 gOAuth "golang.org/x/oauth2/google" 17 gOAuth "golang.org/x/oauth2/google"
18 "google.golang.org/appengine" 18 "google.golang.org/appengine"
19 "google.golang.org/appengine/remote_api" 19 "google.golang.org/appengine/remote_api"
20 ) 20 )
21 21
22 // RemoteAPIScopes is the set of OAuth2 scopes needed for Remote API access.
23 var RemoteAPIScopes = []string{
dnj 2016/01/26 05:21:35 This is useful when using external authentication
24 "https://www.googleapis.com/auth/appengine.apis",
25 "https://www.googleapis.com/auth/userinfo.email",
26 "https://www.googleapis.com/auth/cloud.platform",
27 }
28
22 type key int 29 type key int
23 30
24 var ( 31 var (
25 prodContextKey key 32 prodContextKey key
26 prodContextNoTxnKey key = 1 33 prodContextNoTxnKey key = 1
27 probeCacheKey key = 2 34 probeCacheKey key = 2
28 ) 35 )
29 36
30 // AEContext retrieves the raw "google.golang.org/appengine" compatible Context. 37 // AEContext retrieves the raw "google.golang.org/appengine" compatible Context.
31 // 38 //
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 rsp, err = client.Get(u) 139 rsp, err = client.Get(u)
133 if err != nil { 140 if err != nil {
134 return 141 return
135 } 142 }
136 defer rsp.Body.Close() 143 defer rsp.Body.Close()
137 } else { 144 } else {
138 aeCtx := AEContextNoTxn(*inOutCtx) 145 aeCtx := AEContextNoTxn(*inOutCtx)
139 if aeCtx == nil { 146 if aeCtx == nil {
140 aeCtx = context.Background() 147 aeCtx = context.Background()
141 } 148 }
142 » » » client, err = gOAuth.DefaultClient(aeCtx, 149 » » » client, err = gOAuth.DefaultClient(aeCtx, RemoteAPIScope s...)
143 » » » » "https://www.googleapis.com/auth/appengine.apis" ,
144 » » » » "https://www.googleapis.com/auth/userinfo.email" ,
145 » » » » "https://www.googleapis.com/auth/cloud.platform" ,
146 » » » )
147 if err != nil { 150 if err != nil {
148 return 151 return
149 } 152 }
150 } 153 }
151 } 154 }
152 155
153 aeCtx, err := remote_api.NewRemoteContext(host, client) 156 aeCtx, err := remote_api.NewRemoteContext(host, client)
154 if err != nil { 157 if err != nil {
155 return 158 return
156 } 159 }
157 *inOutCtx = setupAECtx(*inOutCtx, aeCtx) 160 *inOutCtx = setupAECtx(*inOutCtx, aeCtx)
158 return nil 161 return nil
159 } 162 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698