Skip to content
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

Added example to get userInfo when using latest base image #444

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions source/documentation/apps/rshiny-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,20 @@ You can access the full user profile by making a request directly from the RShin
profile <- fromJSON(content(GET("http://localhost:3001/userinfo", add_headers(cookie=get("HTTP_COOKIE", envir=session$request))), "text"))
```

If you are using an R-Shiny base image that is at v1.3.0 or greater, use the example below to get the user data:

```r
# library(httr)
# library(jsonlite)

cookie=get("HTTP_COOKIE", envir=session$request)
headers <- c(
"App-Cookie" = cookie
)

profile <- fromJSON(content(GET("http://localhost:3001/userinfo", add_headers(.headers = headers)), "text"))
```

[This line](https://github.com/moj-analytical-services/shiny-headers-demo/blob/c274d864e5ee020d3a41497b347b299c07305271/app.R#L61)
shows the code in context.

Expand Down