-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathget_me.go
43 lines (36 loc) · 1.04 KB
/
get_me.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
35
36
37
38
39
40
41
42
43
package main
import (
"context"
"fmt"
"os"
"github.com/grokify/goauth"
"github.com/grokify/goauth/authutil"
"github.com/grokify/mogo/config"
"github.com/grokify/mogo/fmt/fmtutil"
ru "github.com/grokify/go-ringcentral-client/office/v1/util"
)
func main() {
_, err := config.LoadDotEnv([]string{os.Getenv("ENV_PATH"), "./.env"}, 1)
if err != nil {
panic(err)
}
apiClient, err := ru.NewApiClientPassword(
goauth.CredentialsOAuth2{
ServerURL: os.Getenv("RINGCENTRAL_SERVER_URL"),
ClientID: os.Getenv("RINGCENTRAL_CLIENT_ID"),
ClientSecret: os.Getenv("RINGCENTRAL_CLIENT_SECRET"),
GrantType: authutil.GrantTypePassword,
Username: os.Getenv("RINGCENTRAL_USERNAME"),
Password: os.Getenv("RINGCENTRAL_PASSWORD")})
if err != nil {
panic(err)
}
info, resp, err := apiClient.UserSettingsApi.LoadExtensionInfo(context.Background(), "~", "~")
if err != nil {
panic(err)
} else if resp.StatusCode >= 300 {
panic(fmt.Errorf("API Status %v", resp.StatusCode))
}
fmtutil.PrintJSON(info)
fmt.Println("DONE")
}