What is the difference between app engine and cloud endpoints when developing with Android studio? - google-app-engine

I've been trying to do this for a while, but I'm confused as to the difference between the two applications.
I know that endpoints helps you expose an API and generate the client libraries that allow you to interact with your Android app.
But in the examples, it seems as though endpoints is the only code you write for the backend at all.
I thought that app engine was what the actual application ran on - that is, do I need a separate project with the app engine backend, then my android studio project with the Android app and the endpoints API, or does writing the endpoints API also serve as the app engine backend?

The endpoints backend API is just a piece of a GAE app functionality.
If you only have that functionality in your app you can extend it by adding the desired stuff to the existing app.yaml file (and the related app code), you don't have to create a new app. Especially if the endpoints functionality and the additional desired functionality are related.
You can also add endpoints backend support to an existing GAE app by merging the endpoints backend app.yaml content into the existing app's app.yaml file and adding the class file and API server file to the app's code.

Related

How to setup Google IAP between 2 Google App Engine Apps

I have a frontend project and a backend project. These are 2 separate app engine projects.
Setting up IAP on both is not problem but when my frontend project tries to call the backend project it is blocked.
Is there anyway to have access allowed to the backend project when the user passes the frontend IAP ? or do I have to leave the backend project without IAP enabled ?
You have to programmatically invoke (make the call using an OIDC token) to the backend from your front end. See documentation on how to do that.
There are misunderstandings. Let me clarify.
Firstly, your App Engine is highly scalable in a single project. Instead of having several projects with several App Engine, you should have only one project, with a single App Engine and multiple services.
Default is usually used for the frontend part. You can use an API service for your backend, or name it as you wish.
Like that, the whole website will be protected by the same IAP context. Like that, no issue as you have before, it's the same IAP cookies and the API calls should not create issues.
Secondly, keep in mind that your JS code runs in the client browser, not on App Engine; App Engine only serves the static files, that's all. All the rest of the computation is performed locally.

Why can't I deploy a React app to Google Cloud Storage?

In the past when I've created a client-side web app using a framework like React, I can create a browser build and push it to a static hosting platform like AWS S3.
For Google Cloud Platform, it seems like the go-to approach is to deploy it to App Engine. If I'm understanding correctly, GAE is a combination of storage and compute resources.
Why can't I simply host the JavaScript app as prepared by webpack?
Google Cloud Storage (GCS) would be the way to go to host your static website on Google Cloud Platform (GCP). Notice that in order to use GCS you'll need to have a domain as well as a GCP project. The documentation is very straightforward on how to achieve this. Here you can find some examples and other useful information.
You could also host your static website on Google App Engine (GAE). But in this case you'll need to cleverly build your app.yaml file in order to manage your URL handlers, as well as structuring your project in a particular way. Simply uploading the JS app as prepared by webpack won't work. You can find all the useful information here in order to use GAE to host your static website.

Developing a web client without servlet

I m new to appengine development.I have a few basic question about web client for appengine.When we make a google cloud module in Android Studio, an android client, a back end and a WEB CLIENT is auto-generated.A few files are auto-generated for web interface. My questions are:
why do I need WEB-INF/web.xml for web client? I also found there's a servlet api dependency added in gradle, though I didnt find and servlet file, what is it used for ?
I want to make a web interface/client for my andorid app, but I dont
know servlet,jsp, can I make it with pure javascript or js lib?
Will the default template for web client work from any other web-hosting
than appengine?
How can I make a web client with pure javascript,css,html, will the
google cloud doc for javascript suffice for this purpose?
why do I need WEB-INF/web.xml for web client? I also found there's a
servlet api dependency added in gradle, though I didnt find and
servlet file, what is it used for ?
Both are base elements for Java web applications even though you are not using servlets most modern web frameworks are built on top of them.
I want to make a web interface/client for my andorid app, but I dont
know servlet,jsp, can I make it with pure javascript or js lib?
Yes, GAE are standard web applications so you can build and app using pure HTML + js.
Will the default template for web client work from any other
web-hosting than appengine?
short answer, no. The App engine SDK depends on several APIs available strictly on the GAE environment. Shouldn't be hard to get an empty webapp template working on a tomcat thought.
How can I make a web client with pure javascript,css,html, will the
google cloud doc for javascript suffice for this purpose?
I dont know exactly what you mean by "the Google cloud Doc" but mostly the answer is yes, all App Engine, Cloud Compute and Google Drive are capable of hosting HTML+JS.

how can I use google app engine with an application in phonegap

I have been developing a Phonegap client application, I need to create a web service that storage all the data that i will be sending through the app.
I want to use google app engine to create the database and the web service.
I have read a lot, but i don't find a concrete example of how to do it and how to call the web service then from the application with phonegap.
Anyone have an example of how to do this?
You can use Cloud Endpoints with your app:
Google Cloud Endpoints consists of tools, libraries and capabilities
that allow you to generate APIs and client libraries from an App
Engine application, referred to as an API backend, to simplify client
access to data from other applications. Endpoints makes it easier to
create a web backend for web clients and mobile clients such as
Android or Apple's iOS.
For mobile developers, Endpoints provides a simple way to develop a
shared web backend and also provides critical infrastructures, such as
OAuth 2.0 authentication, eliminating a great deal of work that would
otherwise be needed. Furthermore, because the API backend is an App
Engine app, the mobile developer can use all of the services and
features available in App Engine, such as Datastore, Google Cloud
Storage, Mail, Url Fetch, Task Queues, and so forth. And finally, by
using App Engine for the backend, developers are freed from system
admin work, load balancing, scaling, and server maintenance.
It is possible to create mobile clients for App Engine backends
without Endpoints. However, using Endpoints makes this process easier
because it frees you from having to write wrappers to handle
communication with App Engine. The client libraries generated by
Endpoints allow you to simply make direct API calls.
Available in Python | Java
we have done similar thing for our Cordova/ionic based application. Its very simple and straight forward using javascript client of google cloud endpoint.

Google App Engine Backends not associated to any Frontend

I'm developing a Java app in GAE, which offers an API through Google Cloud Endpoints.
Basically it receives requests in the endpoints and uses a number of web services from different providers, stores some data and returns some data through the endpoints...
I understand that my app is conceptually a backend, because it doesn't provide any web page, but only the endpoints, don't you think so?
But there's no way to create only a backend, without being associated to any frontend app, is there? At least Google Plugin for Eclipse only allow you to "Generate App Engine Backend", from an existing app, and moreover this app must be an Android project...
I'm using it as a frontend and there's no problem, but apart from the conceptual issue, I've read that backends are kind of optimized to be backends, with more memory and CPU...
I think you're just confused because the Cloud Endpoints documentation uses the word 'backend' to refer to the entire cloud-hosted server implementation. It doesn't specifically refer to the use of GAE backend instances. Endpoint requests can be served by frontend or backend instances, based on how you set them up and the url being accessed.
From the App Ending docs:
"When an application is called to serve a web request, it must issue a response within 60 seconds"
"App Engine Backends are instances of your application that are exempt from request deadlines and have access to more memory (up to 1GB) and CPU (up to 4.8GHz) than normal instances."
So unless you're requests are doing something crazy, you don't need to use a backend. In the google-plugin-for-eclipse, "generate appengine backend" is talking about creating a backend for your android app... a server for your android app to contact (in this case your android app is the frontend and you're appengine app is the backend). In the example app you can remove the web side (index.html) to the appengine application and you'll have no web frontend. Index.html is using the gapi javascript library to make endpoints calls to your appengine service.

Resources