I have successfully resolved the issue. To begin, make sure to include the following code in the ui.R
js function:
www/js/getLogin.js
:
function requestLogin() {
var client = new XMLHttpRequest();
client.open("GET", "yourshinyhostname", true);
client.send();
client.onreadystatechange = function() {
var resposne = client.getResponseHeader("X-Remote-User");
Shiny.onInputChange("getLogin", resposne);
}; }
Next, retrieve the value of X-Remote-User, for example, by clicking a button:
ui.R
:
includeScript("www/js/getLogin.js"),
uiOutput("login_btn"),
verbatimTextOutput("text")
server.R
:
output$login_btn <- renderUI({
HREF <- sprintf('
<button id="get_login_btn" value="test" onclick="requestLogin();" >
<font color="black">
<i class="fa fa-user"></i> Get login
</font>
</button>
')
HTML(HREF)
})
jsOutput <- reactive({
input$getLogin
})
output$text <- renderPrint({
jsOutput()
})