Arttii
Arttii4mo 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!
2 Replies
Rajat
Rajat4mo 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 🙂
Raccine
Raccine3mo ago
Hi there @Arttii! I'm following up to see if Rajat's response was helpful and allowed you to resolve your issue? ☺️

Did you find this page helpful?