Skip to content

oauth2.NoContext deprecated and unnecessary use of fmt.Sprintf #648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions google/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

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

// Handle the exchange code to initiate a transport.
tok, err := conf.Exchange(oauth2.NoContext, "authorization-code")
tok, err := conf.Exchange(context.Background(), "authorization-code")
if err != nil {
log.Fatal(err)
}
client := conf.Client(oauth2.NoContext, tok)
client := conf.Client(context.Background(), tok)
client.Get("...")
}

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

Expand All @@ -84,7 +84,7 @@ func ExampleSDKConfig() {
}
// 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 := conf.Client(context.Background())
client.Get("...")
}

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

Expand Down
2 changes: 1 addition & 1 deletion oauth2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func TestExchangeRequest_JSONResponse_Expiry(t *testing.T) {
}{
{"normal", fmt.Sprintf(`"expires_in": %d`, seconds), true, false},
{"paypal", fmt.Sprintf(`"expires_in": "%d"`, seconds), true, false},
{"issue_239", fmt.Sprintf(`"expires_in": null`), true, true},
{"issue_239", `"expires_in": null`, true, true},

{"wrong_type", `"expires_in": false`, false, false},
{"wrong_type2", `"expires_in": {}`, false, false},
Expand Down