Hi, while using Prefect v1 we needed to identify a...
# ask-community
d
Hi, while using Prefect v1 we needed to identify a user's email in-flight for a flow they triggered, the solution required a GraphQL query. I'm now migrating the same flow to Prefect v2 and wanted to check if the way forward is to use the REST API to fetch the user info, or if there is another way to do this? Thank you
n
Hi @Dan Morris - take a look at the in-app API docs for info about what endpoints are available. In particular I think the
/api/users/{id}
endpoint will be of interest to you
d
Awesome speedy reponse 🙂 I'll take a look, thank you
👍 1
I've hit an issue, not sure if it's by design: If I create a flow run within my personal account I can retrieve the "created_by" element using an API call, the "id" of which relates to me as the creating user and details retrievable using /api/users/{id} as stated. Doing the same in the corporate workspace results in "not found" as the "id" retrieved is actually an account id - can be used with /api/accounts/{id} but cannot be used to identify the individual that created the flow. Am I missing something?
Oh wait...my postman.com wasn't set up correctly, I'll test again and come back...
Ok so ignore the bit about it working as an acocunt_id, the rest of what I said remains true - works on my personal account but not the corporate workspace
I've worked out it has something to do with authentication, if I create an API key under my user then I can see my details, makes sense - but I was hoping a service account API key would be able to see all corporate user info, I'll dig a bit more
Yeah service account with full admin role and all permissions still fails to see my user info :-(
n
Hm I don’t remember off the top of my head how that route interacts with permissions for service accounts but it’s possible a more appropriate route for what you’re doing would be
/api/accounts/{account_id}/workspaces/{workspace_id}/user_access/{id}
- if that’s not quite what you’re looking for, would you mind opening a ticket describing what your use case is?
d
Thanks for helping with this, but I'm not sure how to implement what you've shared here. Can you guide me to what the {id} value would be please? My testing results in an 404 error "Workspace Actor Access not found" when using the user id
n
My apologies, I misunderstood what that route was keying on (it’s not user-id); can you confirm that the service account you’re attempting to use has been invited to the workspace(s) you’re looking to enumerate users for?
d
This message contains interactive elements.
n
@Dan Morris if you visit the workspace sharing screen (accessible from the left side navigation at the bottom if you’re in a workspace), you should be able to see the service accounts that have access to the workspace. You’ll need to manually add the one you’re trying to use
d
Oh I see, yeah I hadn't realised that was a separate step - as it turns out though it must be automatic as all the service accounts we've created are already listed with the workspace roles chosen at the time of creation
n
Ah ok, it’s possible you have default access configured. This sounds like a bug - as I understand it you’re working with our support team already on this but I’m going to ping them just in case. To make sure I understand correctly, you’re just trying to fetch information about the user that triggered a flow run, right?
(or service account)
d
That's correct, thank you for patiently going through this 🙂
n
No thank you! I’ll have them communicate with you from here since there’s not a ton more I can do at the moment; feel free to reach out if needed!
d
Hi, bumping this as not heard anything from support on this at this time
n
Hi @Dan Morris I’ve just pinged the team, sorry that happened but someone will reach back out shortly
d
Thanks @nicholas - Darren Pinder has been in touch via email
🙌 1