Arttii
Arttii•6d ago

Get User Org Golang

How is it possible to get a requesting users' Organization metadata in Golang? Essentially, I have the bearer token after introspection and I would like to fetch the metadata on the organization. If the user is a manager on the Org this will work, but how can i set this up for say externally authenticated users, without manual intervention or having to call webhooks and assigning permission. Currently, we are using the actions to add this to claims, but due to the way actions 2 is working, I am wondering if it's worth doing it like that or just fetch it in the backend. Thanks!
1 Reply
Rajat
Rajat•3d ago
hey @Arttii thanks for your question, you can get user's metadata by their key and/or by id in golang.
getReq := &pb.GetUserMetadataRequest{
Id: "my-id",
Key: "my-key",
}
getmetadataResp, err := client.GetUserMetadata(ctx, getReq)
if err != nil {
log.Fatalln("call failed: ", err)
}

log.Printf("metadata set : %v \n", getmetadataResp.Metadata)
getReq := &pb.GetUserMetadataRequest{
Id: "my-id",
Key: "my-key",
}
getmetadataResp, err := client.GetUserMetadata(ctx, getReq)
if err != nil {
log.Fatalln("call failed: ", err)
}

log.Printf("metadata set : %v \n", getmetadataResp.Metadata)
here client is YOUR client that you will create with management.NewClient() hope this helps 🙂

Did you find this page helpful?