2

I am trying to get a company owned devices via https://cloud.google.com/identity/docs/reference/rest/v1/devices/list using golang. I have tried using a service account and doing domain wide delegation and even adding scopes . It seems that the below code always giving empty values(no devices list).

Sample golang code that I used:

cloudidentityService, err := cloudidentity.NewService(context.Background(), option.WithCredentialsFile("test.json"),
    option.WithScopes("https://www.googleapis.com/auth/cloud-identity.devices.lookup",
        "https://www.googleapis.com/auth/cloud-identity.groups","https://www.googleapis.com/auth/cloud-identity.groups.readonly",
        "https://www.googleapis.com/auth/cloud-platform"))

addevices, err := cloudidentityService.Devices.List().Do()

if len(addevices.Devices) == 0 {
    fmt.Println("empty")
} else {
    for _, u := range addevices.Devices {
        fmt.Println(u.Name)
    }
    return
    

Pls advise. Stuck badly Ref code I used is https://github.com/googleapis/google-api-go-client/blob/master/cloudidentity/v1beta1/cloudidentity-gen.go If anyone can advise via postman that would be great too.

DEVTEAM
  • 21
  • 2

0 Answers0