Get login details from a User Profile using Go Lang SDK

Hi All,

We are trying to retrieve the list of users with the associated groups using Go SDK. However, we were unable to get the profile login details from client.User.ListUsers(). In short, we would like to get the details in the below format.
and so on.

Below is the code we have written for this usecase and when we run this, we get the following error.
username.Profile.login undefined (type *okta.UserProfile has no field or method login)

func main() {
// To Get Group with name
oktaurl := os.Getenv(“OKTAURL”)
oktatoken := os.Getenv(“OKTATOKEN”)
client, _ := okta.NewClient(context.Background(), okta.WithOrgUrl(oktaurl), okta.WithToken(oktatoken), okta.WithCache(false))
filter := query.NewQueryParams(query.WithFilter(“status eq “ACTIVE””))
users, _, _ := client.User.ListUsers(filter)
var userids string
var userlogin string
//Getting user names & IDs
for _, tmpuser := range users {
userids = append(userids, tmpuser.Id
userlogin = append(username, tmpuser.Profile.Login)

    //Getting users for each group
    for i, userid := range userids {
            groups, resp, err := client.User.ListUserGroups(userid, nil)
            if err != nil {
            fmt.Println("UserLogin", userlogin[i])
            for _, groupname := range groups {


Appreciate if someone can help me with this.

Many thanks in advance,

Can you try fmt.Println((*tmpuser.Profile)["login"])
This should print the login value.

It worked perfect. Thank you so much.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.