mirror of
https://github.com/cubixle/ebay.git
synced 2026-04-30 14:18:40 +01:00
Update README
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user