-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_current_user #54
Comments
We just added #51. So should we plan to update those guides to use the SDK to get the user? Or something else? |
The API call in #51 will return the user who owns the API key the client is configured to use. The scenario here is a deployed app that wants to know the identity of visiting users who are identified to Connect (but not the app) via a session cookie. Connect embeds their information in an HTTP header that the app receives. Code to extract HTTP headers from the inbound request is framework-specific. |
Is e.g., client.visitor |
I'm not sure it comes from |
That was what I had in mind. |
Got it. Is I'm thinking the following where get_visitor is the tbd helper method import json
from posit.connect import Client
def get_visitor() -> dict:
return {'username': 'taylor_steinberg', 'groups': ['rsc_team']}
with Client() as client:
visitor = get_visitor()
user = client.users.find_one(lambda user: user["username"] == visitor["username"])
print(json.dumps(user)) |
I think "visitor" is fine and it's a word we use in other places in the documentation. A good alternative is "viewer"--it overlaps with the Connect role, which I think is fine in this case. |
Shiny supports this via
session.user
, for other frameworks we should support this via SDK:The text was updated successfully, but these errors were encountered: