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