-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
34 lines (28 loc) · 921 Bytes
/
main.go
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
29
30
31
32
33
34
package main
import (
"fmt"
"os"
"github.com/heppu/instagram-token-fetcher"
"gopkg.in/alecthomas/kingpin.v2"
)
var (
clientId = kingpin.Flag("client-id", "application client ID").Short('i').Required().String()
redirectUrl = kingpin.Flag("url", "redirect url").Short('r').Required().String()
igUser = kingpin.Flag("user", "instagram username").Short('u').Required().String()
igPassword = kingpin.Flag("password", "password for user").Short('p').Required().String()
scope = kingpin.Flag("scope", "scope for access token").Short('s').Strings()
)
func main() {
kingpin.Parse()
tokenClient := igtoken.NewClient(*clientId, *redirectUrl, *igUser, *igPassword)
scopes := make([]igtoken.Scope, 0)
for _, s := range *scope {
scopes = append(scopes, igtoken.Scope(s))
}
token, err := tokenClient.GetToken(scopes...)
if err != nil {
fmt.Fprint(os.Stderr, err)
return
}
fmt.Print(token)
}