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:
Patrick Jones
2021-08-04 21:45:42 +00:00
committed by Cody Oss
parent a41e5a7819
commit 6f1e639406
2 changed files with 34 additions and 3 deletions

View File

@@ -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: