transport/grpc,option: warn about using an API key with a gRPC client.

- Add a log message to the gRPC dial function if it sees an API key.
  (We could make it an error, but that might break users who accidentally include it.)

- Document that option.WithAPIKey cannot be used for gRPC clients.

Change-Id: I3625cc7b1edc8a47c6b9b930586a3248bab12986
Reviewed-on: https://code-review.googlesource.com/30650
Reviewed-by: Jean de Klerk <deklerk@google.com>
diff --git a/option/option.go b/option/option.go
index ffbee32..c1499f9 100644
--- a/option/option.go
+++ b/option/option.go
@@ -153,6 +153,9 @@
 
 // WithAPIKey returns a ClientOption that specifies an API key to be used
 // as the basis for authentication.
+//
+// API Keys can only be used for JSON-over-HTTP APIs, including those under
+// the import path google.golang.org/api/....
 func WithAPIKey(apiKey string) ClientOption {
 	return withAPIKey(apiKey)
 }
diff --git a/transport/grpc/dial.go b/transport/grpc/dial.go
index 2b8ed6b..ed78fce 100644
--- a/transport/grpc/dial.go
+++ b/transport/grpc/dial.go
@@ -19,6 +19,7 @@
 
 import (
 	"errors"
+	"log"
 
 	"golang.org/x/net/context"
 	"google.golang.org/api/internal"
@@ -62,6 +63,9 @@
 	if insecure {
 		grpcOpts = []grpc.DialOption{grpc.WithInsecure()}
 	} else if !o.NoAuth {
+		if o.APIKey != "" {
+			log.Print("API keys are not supported for gRPC APIs. Remove the WithAPIKey option from your client-creating call.")
+		}
 		creds, err := internal.Creds(ctx, &o)
 		if err != nil {
 			return nil, err