Update README

This commit is contained in:
JBP
2019-08-18 23:59:33 +02:00
parent 84d4471770
commit 65570e9b25
+6 -3
View File
@@ -25,6 +25,7 @@ import (
"context" "context"
"golang.org/x/oauth2" "golang.org/x/oauth2"
"golang.org/x/oauth2/clientcredentials" "golang.org/x/oauth2/clientcredentials"
"github.com/jybp/ebay"
) )
func main() { func main() {
@@ -34,11 +35,12 @@ func main() {
TokenURL: ebay.OAuth20SandboxEndpoint.TokenURL, TokenURL: ebay.OAuth20SandboxEndpoint.TokenURL,
Scopes: []string{ebay.ScopeRoot /* your scopes */}, Scopes: []string{ebay.ScopeRoot /* your scopes */},
} }
tc := oauth2.NewClient(context.Background(), ebay.TokenSource(cfg.TokenSource(ctx))) ctx := context.Background()
tc := oauth2.NewClient(ctx, ebay.TokenSource(cfg.TokenSource(ctx)))
client := ebay.NewSandboxClient(tc) client := ebay.NewSandboxClient(tc)
// Get an item detail. // Get an item detail.
result, err := client.Buy.Browse.GetItem(context.Background(), "v1|123456789012|0") result, err := client.Buy.Browse.GetItem(ctx, "v1|123456789012|0")
} }
``` ```
@@ -49,7 +51,7 @@ An example for the [authorization code grant flow](https://developer.ebay.com/ap
import ( import (
"context" "context"
"golang.org/x/oauth2" "golang.org/x/oauth2"
"golang.org/x/oauth2/clientcredentials" "github.com/jybp/ebay"
) )
func main() { func main() {
@@ -66,6 +68,7 @@ func main() {
var authCode string /* Retrieve the authorization code. */ var authCode string /* Retrieve the authorization code. */
ctx := context.Background()
tok, err := oauthConf.Exchange(ctx, authCode) tok, err := oauthConf.Exchange(ctx, authCode)
if err != nil { if err != nil {
panic(err) panic(err)