Skip to content

Instantly share code, notes, and snippets.

@ctaggart
Created October 20, 2016 07:03
Show Gist options
  • Save ctaggart/9f9ab43171fbe8b02d6a9a39281f7bae to your computer and use it in GitHub Desktop.
Save ctaggart/9f9ab43171fbe8b02d6a9a39281f7bae to your computer and use it in GitHub Desktop.
AppEngine Auth
ctx := appengine.NewContext(request)
hc := &http.Client{
Transport: &oauth2.Transport{
Source: oauth2.StaticTokenSource(&oauth2.Token{AccessToken: githubToken}),
Base: &urlfetch.Transport{Context: ctx},
},
}
func dialService(ctx context.Context, address string) (*grpc.ClientConn, error) {
dialer := func(addr string, timeout time.Duration) (net.Conn, error) {
return socket.DialTimeout(ctx, "tcp", addr, timeout)
}
return grpc.Dial(address, grpc.WithInsecure(), grpc.WithDialer(dialer))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment