I am writing a Python program part of which authenticates with OAuth 1.0 to access a privileged API. I have figured out how to get the authorization URL. After signing in, the browser redirects to http://localhost which I registered as the callback with the provider. How do I get the request to localhost and continue with my bot? I figure I need to have a http server of some sort. I would rather not install a full Apache server. What is a lightweight alternative that can receive the request and forward the token to my bot code to continue with API calls?
Asked
Active
Viewed 720 times
0
-
Hi! Give a try to: https://www.ritlabs.com/en/products/tinyweb/ – Kalma Jan 11 '20 at 20:26
-
@Kalma that wont help OP ... the problem is that google cannot callback to localhost ... it needs a publically accessible url ... i would recommend a tool like **ngrok** that will expose your localhost with a public url that google can call back to (or adjust your router to allow traffic on some ports, and use your external api instead of localhost) – Joran Beasley Jan 11 '20 at 20:28
-
You're right. Sorry, didn't realize google can't callback your localhost... One possible option is to get your external IP address within your python script, then use that address in your call to google instead of your localhost. You can do that using ipify. See issue here: https://stackoverflow.com/questions/2311510/getting-a-machines-external-ip-address-with-python – Kalma Jan 11 '20 at 20:31
-
when you set localhost then Google should display token in browser and user would have to manually copy it. Google can't access localhost server. You would need server accessible from internet - as @JoranBeasley said. You can try ngrok but free version may change url in every restart so it can be useless. You would rather redirect port 80 (for http) in router to your local computer or you would have to use some external server for this. – furas Jan 11 '20 at 20:33