Пример #1
0
func main() {
	flag.Parse()

	client := gogyazo.NewClient(
		os.Getenv("OAUTH2_GYAZO_CLIENT_ID"),
		os.Getenv("OAUTH2_GYAZO_CLIENT_SECRET"),
		os.Getenv("OAUTH2_GYAZO_REDIRECT_URI"),
	)
	if client.HttpClient == nil {
		if *code == "" {
			fmt.Println(client.AuthCodeUrl)
			return
		} else {
			client.Exchange(*code)
		}
	}
	fmt.Printf("%+v\n", client.Transport.Token.AccessToken)
}
Пример #2
0
func main() {
	flag.Parse()

	client := gogyazo.NewClient(
		os.Getenv("OAUTH2_GYAZO_CLIENT_ID"),
		os.Getenv("OAUTH2_GYAZO_CLIENT_SECRET"),
		os.Getenv("OAUTH2_GYAZO_REDIRECT_URI"),
	)
	if client.HttpClient == nil {
		log.Fatalf("Get access token first")
	}

	images, err := client.Images()
	if err != nil {
		log.Fatal(err)
	}
	for _, image := range images {
		fmt.Printf("%+v\n", image)
	}
}