Skip to content

Instantly share code, notes, and snippets.

@yiting007
Created May 7, 2015 23:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yiting007/fbd1e13165e3c69b59b7 to your computer and use it in GitHub Desktop.
Save yiting007/fbd1e13165e3c69b59b7 to your computer and use it in GitHub Desktop.
GAE get service account client
package gaeOauth
import (
"golang.org/x/net/context"
"golang.org/x/oauth2/google"
"golang.org/x/oauth2/jwt"
)
var scopes = []string{}
const (
email string = "project's email"
privateKey string = "project's private key"
)
func getServiceAccountClient(ctx context.Context) *http.Client {
conf := &jwt.Config{
Email: email,
PrivateKey: []byte(privateKey),
Scopes: scopes,
TokenURL: google.JWTTokenURL,
}
return conf.Client(ctx)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment