R Shiny - how to check query string at start of session

Viewed 88

I have a shiny application in which the user can log into spotify. The way this works is that when pressing a button in my UI, the user get redirected to an official spotify login page, if they grant my app permission, spotify will then redirect them to

https://username.shinyapp.io/myapp/?code=< authentication code >

I can then use that code later to access data etc.

My question is: is there a way to save the querystring at the start of a shiny session?

if the user has started the app (without logging in), the querystring will be empty. If the user is redirected no my app by spotify (which means they logged in) a new session is started, and the querystring will contain the code. Therefore, it would be nice if i could save the querystring at the start of the session.

I thought of the code below. But getQueryString() can only be used in a reactive environment. I dont want to make the proces reactive however, because I dont want changes in the url during the session to affect the authorization process.

server <- function(input, output, session)
{
    code <- getQueryString()$code

    <rest of my code here>
}

Any thoughts on how to go about doing this? Thanks in advance!

0 Answers
Related