oauth2/google: add config type to use Cloud SDK credentials
Change-Id: Ied7fecc0cb155c33faca7766b81221eacb3aa0c0 Reviewed-on: https://go-review.googlesource.com/1670 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Burcu Dogan <jbd@google.com>
This commit is contained in:
committed by
Burcu Dogan
parent
95a9f97e51
commit
ab6e11b96c
@@ -74,6 +74,19 @@ func ExampleJWTConfigFromJSON() {
|
||||
client.Get("...")
|
||||
}
|
||||
|
||||
func ExampleSDKConfig() {
|
||||
// The credentials will be obtained from the first account that
|
||||
// has been authorized with `gcloud auth login`.
|
||||
conf, err := google.NewSDKConfig("")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
// Initiate an http.Client. The following GET request will be
|
||||
// authorized and authenticated on the behalf of the SDK user.
|
||||
client := conf.Client(oauth2.NoContext)
|
||||
client.Get("...")
|
||||
}
|
||||
|
||||
func Example_serviceAccount() {
|
||||
// Your credentials should be obtained from the Google
|
||||
// Developer Console (https://console.developers.google.com).
|
||||
|
||||
Reference in New Issue
Block a user