google: set token type on returned JWTAccessToken, tweak docs
Change-Id: Id83af8110c7c89ca5ffe793149230fa3f87a6baf
Reviewed-on: https://go-review.googlesource.com/14198
Reviewed-by: Dave Day <djd@golang.org>
diff --git a/google/jwt.go b/google/jwt.go
index 25d1292..804d9d0 100644
--- a/google/jwt.go
+++ b/google/jwt.go
@@ -19,6 +19,10 @@
// requests, and returns a TokenSource that does not use any OAuth2 flow but
// instead creates a JWT and sends that as the access token.
// The audience is typically a URL that specifies the scope of the credentials.
+//
+// Note that this is not a standard OAuth flow, but rather an
+// optimization supported by a few Google services.
+// Unless you know otherwise, you should use JWTConfigFromJSON instead.
func JWTAccessTokenSourceFromJSON(jsonKey []byte, audience string) (oauth2.TokenSource, error) {
cfg, err := JWTConfigFromJSON(jsonKey)
if err != nil {
@@ -63,5 +67,5 @@
if err != nil {
return nil, fmt.Errorf("google: could not encode JWT: %v", err)
}
- return &oauth2.Token{AccessToken: msg}, nil
+ return &oauth2.Token{AccessToken: msg, TokenType: "Bearer"}, nil
}