google/downscope: update documentation
Change-Id: Ib4dfc7b554c1e7565cc61bc372a98ddd390e7453 GitHub-Last-Rev: 63894e56810431f8a45d381f4ffb123da1a1b8e0 GitHub-Pull-Request: golang/oauth2#512 Reviewed-on: https://go-review.googlesource.com/c/oauth2/+/338389 Reviewed-by: Cody Oss <codyoss@google.com> Reviewed-by: Chris Broadfoot <cbro@golang.org> Trust: Cody Oss <codyoss@google.com> Trust: Chris Broadfoot <cbro@golang.org> Run-TryBot: Cody Oss <codyoss@google.com> Run-TryBot: Chris Broadfoot <cbro@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
@@ -6,6 +6,7 @@ package downscope_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/oauth2"
|
||||
"golang.org/x/oauth2/google/downscope"
|
||||
@@ -29,8 +30,13 @@ func ExampleNewTokenSource() {
|
||||
|
||||
dts, err := downscope.NewTokenSource(ctx, downscope.DownscopingConfig{RootSource: rootSource, Rules: accessBoundary})
|
||||
if err != nil {
|
||||
_ = dts
|
||||
fmt.Printf("failed to generate downscoped token source: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Enables automatic token refreshing
|
||||
_ = oauth2.ReuseTokenSource(nil, dts)
|
||||
|
||||
// You can now use the token held in myTokenSource to make
|
||||
// Google Cloud Storage calls, as follows:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user