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

make redirect host configurable #61

Open
hacker-h opened this issue Sep 8, 2019 · 3 comments
Open

make redirect host configurable #61

hacker-h opened this issue Sep 8, 2019 · 3 comments
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@hacker-h
Copy link

hacker-h commented Sep 8, 2019

I am using docker for windows which runs the docker daemon inside a Hyper-V VM.
This library is used inside a docker container and for authentication purposes the corresponding port is exposed to my machine. This way I can access the launched WSGI server on localhost on my machine, however the server inside the docker container does only listen on the ip behind localhost resolved within the container -> You do not receive an answer for localhost on your machine, only within the container (e.g. with curl)
This could easily be mitigated by passing an empty String as host parameter to the Flow.run_local_server function, but this will raise an error because the redirect url is equal to the chosen host string -> empty URL is not possible

As a solution the function could be extended by an optional parameter redirect_host that defaults to the value of host and is inserted into the redirect_host variable.

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Sep 8, 2019
@busunkim96 busunkim96 added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed triage me I really want to be triaged. labels Sep 9, 2019
@busunkim96
Copy link
Contributor

Hi @hacker-h,

I'm having a bit of trouble understanding the request. Would you mind providing a short example?

As run_local_server is currently written, the host and port values are used to construct redirect_uri.

@hacker-h
Copy link
Author

You can basically just launch an ubuntu docker container on docker for windows exposing port 8080:

docker run --name testContainer -it -p 8080:8080 ubuntu

follow the quickstart steps from https://developers.google.com/drive/api/v3/quickstart/python

apt update && apt install curl python3-pip -y && pip3 install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib

paste the credentials.json along with the quickstart script into the container (e.g. with cat > FILE or echo '...' > FILE)
https://github.com/gsuitedevs/python-samples/blob/master/drive/quickstart/quickstart.py
Make sure to adapt the port specified in the quickstart script to 8080.

run the script:

python3 quickstart.py

open the printed URL in your browser and confirm the access
At the end you will be redirected to a page localhost:8080?state=[...] which tells you that the server reset the connection while trying to load the page.

Copy the URL and open a terminal to enter your container:

docker exec -it testContainer bash

Use curl to send a GET request against the copied URL from within the container:

curl http://localhost:8080/?state=[...]

You will get an output:

The authentication flow has completed[...]

I hope this helps to reproduce and understand the problem.

@moee
Copy link

moee commented Aug 27, 2021

I ran into the same problem with docker and would find such a feature very useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

4 participants