I support Google Drive SDK 'Open with' at my Go AppEngine based app. Everything works fine for my deployed app. But I cannot setup a valid local AppEngine development setup.
The local AppEngine server runs on http://localhost:8080, therefore my callback for the 'Open with' (Authentication is on) is http://localhost:8080/oauth2callback. But this is not a valid 'Open URL' at the Drive SDK settings (console.developers.google.com). So what's the right setup? Is it not possible to develop 'Open with' functionality with a local AppEngine dev environment?
Jens
Jens,
It's possible to work with OAuth locally but it requires some work, consider that "localhost" means something different for every computer, and that's why it's valid only in a local context. That's why the console does not allow that value.
If you really need to get that callback on your local server you'll need to make your PC's "address" unique and globally accessible, meaning you'll probably have to setup a static IP or Dyniamic DNS and redirect that to your PC so the OAuth provider has a fixed address to locate your PC.
Just edit your /etc/hosts (or windows equivalent) file. Find the line that says
127.0.0.1 localhost
and add (say) mydevserver.me.com
127.0.0.1 localhost mydevserver.me.com
You can then configure mydevsserver.me.com in the Google API Console.
Related
Our AppEngine app is connecting to a remote service which requires a VPN and also required me to add entries to the hosts file on my local machine in order to connect to their endpoints.
e.g.
10.200.30.150 foo.bar.com
This is working fine when running the app locally, but I can't figure out how to set this up on Google Cloud to work once deployed.
I can't use the IP addresses directly because it errors that the IP is not on the cert's list.
How do I map the host names to the IPs in Google Cloud so that AppEngine can use them?
From the error mentioned in the comment I suspect connecting directly through the IP fails because the certificate doesn't recognize the IP to DNS mapping as valid and therefore the secure connection setup breaks. Based on the requirements of connecting to the API by VPN and tweaking the hosts mapping there are few things you may try.
The simplest approach that may work would be using a Google Compute Engine VM instance, since there you would able to manipulate the etc/hosts file and replicate the local machine setup. This VM could be used either as the main app service or as a proxy from App Engine to the 3rd party API endpoint. To go that route I would suggest taking a look at these two posts which explain how to change the etc/hosts file on GCE (Changing the file once wouldn't work as the VM periodically overrides it, see the posts for cronjob like workaround).
Separately, as your app runs in App Engine flexible environment there is the chance to provide a docker container with the app packaged. It may be possible to set the workaround above in the docker file and have it working in App Engine too.
I installed the new XAMPP 7.4 in macOS Catalina and the window is very different than before. I press Mount and it runs. But I have Angularjs projects that calls API Rest Laravel projects in htdocs, but doesn't work because it calls to localhost or to the local IP of the computer, but I don't know how XAMPP works now.
XAMPP creates a new ip where is htdocs and I access to the folder throw the IP but my Angularjs projects can't access because they don't know the IP, only call to 127.0.0.1.
How can I configure XAMPP to work with localhost or how can I configure Angularjs to call to that IP without affect my production server?
Thank you!
Disclaimer: I have not done this before, my answer is based on my angularjs experience and a brief search.
Trying a brand new project
In this article (which you have probably already seen and tried): https://kode-blog.io/angularjs-install-and-configure there is a very relevant segment, namely Step 1: "You can directly create the folder angular-js in drive C:\xampp\htdocs". I understand your issues is just vaguely related, though you could try following this article step-by-step with a brand new project
XAMPP to local/virtual host
If I understood correctly you are looking for a way to modify the XAMPP/AngularJS serving to the same IP. Let's try setting XAMPP to localhost first:
Setting up a virtual host on XAMPP on Mac or How to set xampp open localhost:8080 instead of just localhost and also more detailed, step-by-step ones: https://jonathannicol.com/blog/2012/03/11/configuring-virtualhosts-in-xampp-on-mac/
Serving AngularJS to a specific host
AngularJS is a lot less flexible than Angular 2+ (Set default host and port for ng serve in config file) when it comes to serving a host. You could try using http-server and node.js (first answer here: How to create a localhost server to run an AngularJS project but also check out other answers, there is some extra useful info there)
Extra bits
What you are trying seems to be absolutely feasible and done by others (Setup AngularJS and NodeJS on Xampp Web server or https://www.quora.com/Can-we-use-AngularJS-in-XAMPP) but it's not the most common thing.
I know that this answer does not directly give you an easy-to-implement-one-single-line-of-wondercode, but I hope it will start discussion at least and result in something more useful.
To use a Status IP like localhost:8080, you have to go to the Network tab in XAMPP and press Enable on the localhost:8080 option. I feel ashamed for taking too long to find this. Thank you.
I would like to debug my Google App Engine (GAE) app locally but without using localhost. Since my application is made up of microservices, the urls in a production environment would be along the lines of:
https://my-service.myapp.appspot.com/
But code in one service can call another service and that means that the urls are hardcoded. I could of course use a mechanism in code to determine whether the app is running locally or on GAE and use urls that are different although I don't see how a local url would handle the since the only way to run an app locally is to use localhost. Hence:
http://localhost:8080/some-service
Notice that "some-service" maps to a servlet, whereas "my-service" is a name assigned to a service when the app is uploaded. These are really two different things.
The only possible solution I was able to find was to use a reverse proxy which would map one url to a different one. Still, it isn't clear whether the GAE development SDK even supports this.
Personally I chose to detect the local development vs GAE environment and build my inter-services URLs accordingly. I feel it was a well-worthy effort, I've been (re)using it a lot. No reverse proxy or any other additional ops necessary, it just works.
Granted, I'm using Python, so I'm not 100% sure a complete similar Java solution exists. But maybe it can point you in the right direction.
To build the per-service URLs I used modules.get_hostname() (the implementation is presented in Resolve Discovery path on App Engine Module). I believe the Java equivalent would be getInstanceHostname() from com.google.appengine.api.modules.
This method, when executed on the local server, automatically provides the particular port the server listens to for each service.
BTW, all my services for an app are executed by a single development server process, which listens on multiple ports (this is, I guess, how it can provide the modules.get_hostname() info). See Running multiple services using dev_appserver.py on different ports. This is part I'm unsure about: if/how the java local dev server can simultaneously run multiple services. Apparently this used to be supported some time ago (when services were still called modules):
Serving multiple GAE modules from one development server?
GAE modules on development server
This can be accomplished with the following steps:
Create an entry in the hosts file
Run the App Engine Dev server from a Terminal using certain options
Use IntelliJ with Remote debugging to attach the App Engine Dev server.
To edit the hosts file on a Mac, edit the file /etc/hosts and supply the domain that corresponds to your service:. Example:
127.0.0.1 my-service.myapp.com
After you save this, you need to restart your computer for the changes to take place.
Run the App Engine Dev server manually:
dev_appserver.sh --address=0.0.0.0 --jvm_flag=-Xdebug
--jvm_flag=-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
[path_to_exploded_war_directory]
In IntelliJ, create a debug configuration. Use the Remote template to create this configuration. Set the host to the url you set in the hosts file and set the port to 8000.
You can set a breakpoint and run the app in IntelliJ. IntelliJ will attach to the running instance of App Engine Dev server.
Because you are using a port during debugging and no port is actually used when the app is uploaded to the GAE during production, you need to add code that identifies when the app is running locally and when it's running on GAE. This can be done as follows:
private String mServiceUrl = "my-service.my-app.appspot.com";
...
if (SystemProperty.environment.value() != SystemProperty.Environment.Value.Production) {
mServiceUrl += ":8000";
}
See https://cloud.google.com/appengine/docs/standard/java/tools/using-local-server
An improved solution is to avoid including the port altogether and not having to use code to determine whether your app is running locally or on the production server. One way to do this is to use Charles (an application for monitoring and interacting with requests) and use a feature called Remote Mapping which lets you map one url to another. When enabled, you could map something like:
https://my-service.my-app.appspot.com/
to
https://localhost:8080
You would then enable the option to include the original host, so that this gets delivered to the local dev server. As far as your code is concerned it only sees:
https://my-service.my-app.appspot.com/
although the ip address will be 127.0.0.1:8080 when remote mapping is enabled. To use https on local host however does require that you enable ssl certificates for Charles.
For a complete overview on how to setup and debug microservices for a GAE Java app in IntelliJ, see:
https://github.com/JohannBlake/gae-microservices
I developing an app with GAE as a back-end, when I run GAE server locally I can reach it in the browser through localhost:8888 but when I try to reach from an external device on the same wifi network, with my <my local ip>:8888 I get no response. I was always using this way do debug my apps and back-ends and suddenly it stopped working?
Found the answer at last, add 0.0.0.0 address to the servers run arguments. As described here :
Can access AppEngine SDK sites via local ip-address when localhost works just fine and a MacOSX
https://developers.google.com/appengine/docs/java/tools/devserver#Using_URL_Fetch
I would like to know how can i create a dev environment where I can deploy and test my application with other user and not locally.
Do you have any clue?
Sure, if you have a machine with a public IP address, you could just run the dev_appserver with the -a publicIP (you may also want to do -p 80 to set the port to 80). You then can send your other users to that IP and it will be running the dev environment. If you don't have a machine with a public DNS, you could go the route of DynDNS or just get an Amazon EC2 box for as long as you need it for.
Not sure what feature do you want in "dev" environment. If you're referring to debugging, online GAE environment is not possible. However you can create a private project (with access only open to you and your colleagues) and use LOG/appstat to test it.
Why not just deploy your app? You can always set "login: admin" on all the pages if you only want certain users to use it.