Created
May 7, 2015 23:33
-
-
Save yiting007/fbd1e13165e3c69b59b7 to your computer and use it in GitHub Desktop.
GAE get service account client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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