Shiny Proxy & Google Oauth


#1

So, here’s the context:

I want to create a shiny app that loads Google Analytics user data.

What Shiny Proxy is doing is launching a new webpage each time a user connects, with the url (for example) http://<url>:<port>/app/01_hello/endpoint/xyzabcdefghijklm/ — the id of this endpoint being randomly assigned.

I have on this app (01_hello), a button that sends a request for Oauth. If I am on an already launched app, I can go to the google dev console, and manually enter http://<url>:<port>/app/01_hello/endpoint/xyzabcdefghijklm/ as an authorized URI. And that works.

The thing is that each time I relaunch this app, a new endpoint id is randomly generated. So I can’t anticipate what the endpoint will be for future user.

So, the TLDR being: as each app has a random id paste at the end of the url, I can’t anticipate what this url will be and allow my app to access the Google Console.

Any idea how I could get around that?

Thanks


#2

Hi @colin,

Is the problem here not having a predictable redirect uri?

One approach that may be worth trying, is using a reverse proxy, and adding the state parameter in your auth request.

E.g.

https://accounts.google.com/o/oauth2/auth?state=xyzabcdefghijklm&redirect_uri=http://<host>:<port>/auth_callback

After authentication, the state parameter will be appended onto your redirect uri, so it will look like this:

http://<host>:<port>/auth_callback?state=xyzabcdefghijklm

And combine this with a reverse proxy that rewrites the above URL into

http://<host>:<port>/endpoint/xyzabcdefghijklm