Google Cloud python project has localhost error - python-3.x

I've been following the instructions for this guide:
https://developers.google.com/gmail/api/quickstart/python
to run a basic program which reads a Gmail inbox.
Basically, the program opens up a new window asking you to login with your gmail account - once that is done, it gives the information back to the program which should print results on the google cloud shell terminal.
Whenever I login with the correct google account, the page shows "localhost refused to connect". For this reason, the rest of the program cannot continue, so the google cloud shell is stuck waiting for the login to occur. Would anyone have any ideas on why this localhost error is happening? Thanks in advance.

Solution
Run the code from your desktop.
The OAuth Flow that you are using requires a web browser. This means the webserver process must be running on your system.
You are trying to run code in Cloud Shell. And it does not have one. If you look at the source code run_local_server() starts a webserver. The server is running on the wrong system.
There are methods to create a public webserver (not using localhost). Then the issue becomes how to start the webserver on Cloud Shell.
Except for experimenting you are using the wrong services (Cloud Shell).

Related

Opening the browser from Python running in Google Cloud Shell

I'm developing a small script on Python 3.6, and I'll most likely use it from Google Cloud Shell. In said script, I want to do some API calls, and then, open the web browser with an URL, result of those calls. The following code works in other environments that I have tested on, but not in Cloud Shell:
import webbrowser as wb
# different calls and process here, not relevant to the issue
wb.open('URL_HERE')
#This just echoes the URL.
Is there anyway to make Python 'tell' Cloud Shell to use the browser from where it's running? i.e: if I'm using Chrome to open Cloud Shell, is there any way to open the link in Chrome? It doesn't matter if it's with webbrowser or other library.
Cloud Shell is just a “window” displaying a command line from a remote and temporary Compute Engine virtual machine instance. Meaning that when you run the script, you are actually running it in the remote VM (not in Chrome), and that specific VM does not have a browser by itself.
For example, when you try to run an app in Cloud Shell (here you can find a quick example using "mvn appengine:run"), once the application is running, you will see a message in Cloud Shell, something like:
[INFO] GCLOUD: INFO: Module instance default is running at http://localhost:8080/
If you click on http://localhost:8080/ , you will actually be redirected to the temporary address assigned for the Cloud Shell VM instance (something like 8080-dot-VM-ID-devshell.appspot.com).
In summary, you can’t command Cloud Shell to open the browser with a specific URL shown in the remote VM command line. Also, you should consider that there are outgoing connections limitations and Cloud Shell is intended for interactive use only.

Bot is remote but callback URL is localhost

I want to debug my azure bot with botframework emulator.
Whenever I try to connect, the emulator tells me the bot is remote but the callback URL is localhost.
How can I change this?
It also complains about my ngrok settings, but I am fairly sure that everything's allright about them, because I downloaded ngrok and pasted the correct path to the .exe in the settings.
How can I fix this problem?
Note that I finally get an internal server error.
My Settings in the bot Framework page (as suggested by JustAShadow) are:
the URL you entered in the box for URL on the emulator is supposed to be for local debugging. I.E you run your bot locally, get the URL for that local running bot, and add that localhost url to your bot emulator. you are emulating an actual bot in a bot framework inside a bot framework emulator!
The emulator is built in order to emulate the Bot framework ENV, so that when you run your bot locally, it understands the type of environment you should be running under.
I.E if you get DocumentDb emulator, you dont connect it to a real database, its just pretending to be azure, not Debugging Azure
Assure the MSID and PW are correct in the web.config when you publish

wkhtmltopdf as node module fails when run as windows service

I am running a node app that uses the wkhtmltopdf module (https://www.npmjs.com/package/wkhtmltopdf) and node routing to return a pdf of a page when the user navigates to a /pdf path. Everything works fine when the app is run on in the servers console, but when the app runs as a Windows service, the pdf call fails. I get the browser crash screen with the message that the site refused to connect. The rest of the site works fine, just the path to return PDFs fails, and I can't glean anything from the logs. Is this a known issue with wkhtmltopdf?
OS: Fedora
I had the issue with my node server program and wkhtmltopdf module in it, not generating pdf when run as a service. Turns out that a user for the service was set as nobody and so was usergroup. We removed that entry and reran the service it works.
I am guessing this could be the issue with Windows as well.
Please let me know if it did not work, did work or you already solved the problem with another approach.

net::ERR_CONNECTION_REFUSED when moving app from local machine to remote server

Had a look around at some other threads and there doesn't seem to be someone with this exact problem.
The problem is that I have made a webapp that works fine when hosting it locally. On the app there is a button that causes a request to be sent to my server and it performs as expected on localhost:3000 but when I host it remotely on a linux box purchased from digital ocean the site loads but the when the button is pressed I see
net::ERR_CONNECTION_REFUSED
in the console.
I'm not sure how useful it would be to post code so I will leave that out unless requested. I'm hoping this is due to some server configuration issue?
Further info:
This is a node application on a server running ubuntu. To run the application I use and keep it running I use PM2.
Thanks in advance.

IBM Watson Tradeoff Analytics Back-end service is not available

I'm trying to integrate Watson Tradeoff Analytics service into my external project to SAP WEB IDE, so I have downloaded the following example:
github.com/dolevdotan/tradeoff-analytics-v2-vanilla-nodejs
Inside the Service on Bluemix I got the following credentials
generated
I put this credentials inside app.js
I'm running my service and it's good at the beggining, but in case of pressed button "Help Me Decide" and the following error appears:
Oops! Something went wrong
Back-end service is not available. Please try again later.
The most interesting is now! If I run the following link with deployed official TradeOff Example:
tradeoff-analytics-v2-demo.mybluemix.net/#cars
My own service will work as expected after that, without any errors. But I need to run this link first. Why so strange? What shall I do to correct it and avoid?
Thanks!

Resources