forked from remote/oauth2
downscope: update documentation
This commit is contained in:
@@ -6,11 +6,16 @@ package downscope_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/oauth2"
|
||||
"golang.org/x/oauth2/google/downscope"
|
||||
)
|
||||
|
||||
func Example() {
|
||||
|
||||
}
|
||||
|
||||
func ExampleNewTokenSource() {
|
||||
ctx := context.Background()
|
||||
// Initializes an accessBoundary with one Rule.
|
||||
@@ -29,8 +34,12 @@ 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)
|
||||
}
|
||||
|
||||
// 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