11package main
22
33import (
4- "context"
5- "flag"
6- "fmt"
7- "log"
8- "os"
9- "time"
10-
11- "github.com/rgthelen/ rownd-go-sdk /pkg/rownd"
4+ "context"
5+ "flag"
6+ "fmt"
7+ "log"
8+ "os"
9+ "time"
10+
11+ "github.com/rownd/client -go/pkg/rownd"
1212)
1313
1414func main () {
15- // Parse command line flags
16- var (
17- appKey = flag .String ("app-key" , os .Getenv ("ROWND_APP_KEY" ), "Rownd app key" )
18- appSecret = flag .String ("app-secret" , os .Getenv ("ROWND_APP_SECRET" ), "Rownd app secret" )
19- token = flag .String ("token" , "" , "Rownd authentication token" )
20- )
21- flag .Parse ()
15+ // Parse command line flags
16+ var (
17+ appKey = flag .String ("app-key" , os .Getenv ("ROWND_APP_KEY" ), "Rownd app key" )
18+ appSecret = flag .String ("app-secret" , os .Getenv ("ROWND_APP_SECRET" ), "Rownd app secret" )
19+ token = flag .String ("token" , "" , "Rownd authentication token" )
20+ )
21+ flag .Parse ()
2222
23- // Validate required flags
24- if * appKey == "" || * appSecret == "" {
25- log .Fatal ("app-key and app-secret are required" )
26- }
27- if * token == "" {
28- log .Fatal ("token is required" )
29- }
23+ // Validate required flags
24+ if * appKey == "" || * appSecret == "" {
25+ log .Fatal ("app-key and app-secret are required" )
26+ }
27+ if * token == "" {
28+ log .Fatal ("token is required" )
29+ }
3030
31- // Create client with timeout context
32- ctx , cancel := context .WithTimeout (context .Background (), 10 * time .Second )
33- defer cancel ()
31+ // Create client with timeout context
32+ ctx , cancel := context .WithTimeout (context .Background (), 10 * time .Second )
33+ defer cancel ()
3434
35- client , err := rownd .NewClient (
36- rownd .WithAppKey (* appKey ),
37- rownd .WithAppSecret (* appSecret ),
38- )
39- if err != nil {
40- log .Fatalf ("Failed to create client: %v" , err )
41- }
35+ client , err := rownd .NewClient (
36+ rownd .WithAppKey (* appKey ),
37+ rownd .WithAppSecret (* appSecret ),
38+ )
39+ if err != nil {
40+ log .Fatalf ("Failed to create client: %v" , err )
41+ }
4242
43- // Run the validation
44- if err := run (ctx , client , * token ); err != nil {
45- log .Fatal (err )
46- }
43+ // Run the validation
44+ if err := run (ctx , client , * token ); err != nil {
45+ log .Fatal (err )
46+ }
4747}
4848
4949func run (ctx context.Context , client * rownd.Client , token string ) error {
50- // Validate token
51- tokenInfo , err := client .Tokens .Validate (ctx , token )
52- if err != nil {
53- return fmt .Errorf ("validate token: %w" , err )
54- }
50+ // Validate token
51+ tokenInfo , err := client .Tokens .Validate (ctx , token )
52+ if err != nil {
53+ return fmt .Errorf ("validate token: %w" , err )
54+ }
5555
56- // Get user profile
57- user , err := client .Users .Get (ctx , rownd.GetUserRequest {
58- UserID : tokenInfo .UserID ,
59- })
60- if err != nil {
61- return fmt .Errorf ("get user: %w" , err )
62- }
56+ // Get user profile
57+ user , err := client .Users .Get (ctx , rownd.GetUserRequest {
58+ UserID : tokenInfo .UserID ,
59+ })
60+ if err != nil {
61+ return fmt .Errorf ("get user: %w" , err )
62+ }
6363
64- fmt .Printf ("User profile: %+v\n " , user )
65- return nil
66- }
64+ fmt .Printf ("User profile: %+v\n " , user )
65+ return nil
66+ }
0 commit comments