| 1 |
package putio_test |
| 2 |
|
| 3 |
import ( |
| 4 |
"context" |
| 5 |
"fmt" |
| 6 |
"log" |
| 7 |
|
| 8 |
"github.com/putdotio/go-putio/putio" |
| 9 |
"golang.org/x/oauth2" |
| 10 |
) |
| 11 |
|
| 12 |
const token = "<YOUR-TOKEN-HERE>" |
| 13 |
|
| 14 |
func Example() { |
| 15 |
tokenSource := oauth2.StaticTokenSource( |
| 16 |
&oauth2.Token{AccessToken: token}, |
| 17 |
) |
| 18 |
oauthClient := oauth2.NewClient(context.TODO(), tokenSource) |
| 19 |
client := putio.NewClient(oauthClient) |
| 20 |
|
| 21 |
|
| 22 |
root, err := client.Files.Get(context.TODO(), 0) |
| 23 |
if err != nil { |
| 24 |
log.Fatal(err) |
| 25 |
} |
| 26 |
|
| 27 |
fmt.Printf("Name of root folder is: %s\n", root.Name) |
| 28 |
} |