Skip to content

Commit 99146a0

Browse files
committed
oauth2.NoContext deprecated and unnecessary use of fmt.Sprintf
1 parent 839de22 commit 99146a0

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

google/example_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
)
1818

1919
func ExampleDefaultClient() {
20-
client, err := google.DefaultClient(oauth2.NoContext,
20+
client, err := google.DefaultClient(context.Background(),
2121
"https://www.googleapis.com/auth/devstorage.full_control")
2222
if err != nil {
2323
log.Fatal(err)
@@ -44,11 +44,11 @@ func Example_webServer() {
4444
fmt.Printf("Visit the URL for the auth dialog: %v", url)
4545

4646
// Handle the exchange code to initiate a transport.
47-
tok, err := conf.Exchange(oauth2.NoContext, "authorization-code")
47+
tok, err := conf.Exchange(context.Background(), "authorization-code")
4848
if err != nil {
4949
log.Fatal(err)
5050
}
51-
client := conf.Client(oauth2.NoContext, tok)
51+
client := conf.Client(context.Background(), tok)
5252
client.Get("...")
5353
}
5454

@@ -71,7 +71,7 @@ func ExampleJWTConfigFromJSON() {
7171
// Initiate an http.Client. The following GET request will be
7272
// authorized and authenticated on the behalf of
7373
// your service account.
74-
client := conf.Client(oauth2.NoContext)
74+
client := conf.Client(context.Background())
7575
client.Get("...")
7676
}
7777

@@ -84,7 +84,7 @@ func ExampleSDKConfig() {
8484
}
8585
// Initiate an http.Client. The following GET request will be
8686
// authorized and authenticated on the behalf of the SDK user.
87-
client := conf.Client(oauth2.NoContext)
87+
client := conf.Client(context.Background())
8888
client.Get("...")
8989
}
9090

@@ -116,7 +116,7 @@ func Example_serviceAccount() {
116116
}
117117
// Initiate an http.Client, the following GET request will be
118118
// authorized and authenticated on the behalf of [email protected].
119-
client := conf.Client(oauth2.NoContext)
119+
client := conf.Client(context.Background())
120120
client.Get("...")
121121
}
122122

oauth2_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ func TestExchangeRequest_JSONResponse_Expiry(t *testing.T) {
282282
}{
283283
{"normal", fmt.Sprintf(`"expires_in": %d`, seconds), true, false},
284284
{"paypal", fmt.Sprintf(`"expires_in": "%d"`, seconds), true, false},
285-
{"issue_239", fmt.Sprintf(`"expires_in": null`), true, true},
285+
{"issue_239", `"expires_in": null`, true, true},
286286

287287
{"wrong_type", `"expires_in": false`, false, false},
288288
{"wrong_type2", `"expires_in": {}`, false, false},

0 commit comments

Comments
 (0)