From my backend, I want to list all users for my org( simple stuff).
If I try the following code as seen from okta sdk example, I get an API error with no stack trace or even the API name(have tried setepping through code)
myClient := &http.Client{}
config := okta.NewConfig().WithOrgUrl("https://dev-
/oauth2/default").WithToken("-----")
client := okta.NewClient(config, myClient, nil)
client := core.NewClient()
if(client == nil) {
fmt.Println(“client is null”)
}
fmt.Print(" users: ", *(client.User))
filter := query.NewQueryParams(query.WithFilter(“status eq “ACTIVE””))
users, , err := client.User.ListUsers(filter)
if( err!= nil ) {
println(err.Error())
}
for , u := range users {
fmt.Print(“user id: %v”, u.Id)
}
I can use the below code to access the endpoint directly though and get the expected response.
url := “https://----------oktapreview.com/api/v1/users”
req, _ := http.NewRequest(“GET”, url, nil)
req.Header.Add(“Accept”, “application/json”)
req.Header.Add(“Content-Type”, “application/json”)
req.Header.Add(“Authorization”, “SSWS --------------”)
req.Header.Add(“cache-control”, “no-cache”)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
Any idea what I could be doing wrong while using the okta sdk directly ?
Thanks