Official Content

This document is deprecated. See Deployment of an app to Google App Engine: setting up the environment.

If you're deploying the Java application for the first time from a local machine, consider that the appcfg tool (the tool used to deploy the application to GAE - Google App Engine) uses OAuth 2.0 protocol to authenticate. (The appcfg tool is included with the App Engine SDK, which you can download and install at App Engine Java SDK).

The first time you deploy, you are asked to authorize the appcfg tool. A browser is opened, and there you have to allow the execution of the app.

Since it uses OAuth 2.0, you will need to enter your credentials; afterwards, you'll be given a code whose purpose is to allow the tool to ask for an access token. Using this access token, the deployment can flow normally.

i2017_05_24_18_12_371_png

The access token is needed to set up a file called ".appcfg_oauth2_tokens_java" (located in the user's folder) whose content is similar to the following (note that it includes the access_token needed to deploy the application to Google):

{"credentials":{"sjuarez":{"access_token":"ya29.GltUBAQOueqgY3nfhTDl9qRFuSrxUbAEz34B40-b9bb4S_zn02Guc9BubutrXcdiBRxxxxx","expiration_time_millis":1495636562020,"refresh_token":"1/YGzm0RbZ8aC0BnFjySs2oHj7nJS-RpExxxxxx"}}}

Because these steps are command line- driven, they cannot be executed in the deploy process using the Application Deployment tool.

So, the first time, the Application Deployment tool will fail, showing the following in the log it generates:

java.util.NoSuchElementException: No line found
    at java.util.Scanner.nextLine(Unknown Source)
    at com.google.appengine.tools.admin.PromptReceiver.waitForCode(PromptReceiver.java:25)
    at com.google.appengine.tools.admin.OAuth2Native.authorize(OAuth2Native.java:255)
    at com.google.appengine.tools.admin.AppCfg.authorizeOauth2(AppCfg.java:507)
    at com.google.appengine.tools.admin.AppCfg.<init>(AppCfg.java:183)
    at com.google.appengine.tools.admin.AppCfg.<init>(AppCfg.java:116)
    at com.google.appengine.tools.admin.AppCfg.main(AppCfg.java:112)

You have to execute the deployment manually for the first time, to enter the code given by Google, and to allow the app to generate the ".appcfg_oauth2_tokens_java" file.
So, execute the same command line as the tool, but enter the code when the app requires it:

"C:\soft\appengine-java-sdk-1.9.38\bin\appcfg.cmd" -A iconic-lane-129516 update "C:\Models\SummerReading3\SummerReading1\JavaMySQL013\Deploy\GAE\20170524102705" -V 1
The following URL can be used to authenticate:
  https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force&client_id=xxx.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=https://www.googleapis.com/auth/appengine.admin%20https://www.googleapis.com/auth/cloud-platform
Attempting to open it in your browser now.
Please enter code: XXXXXXXXXXXXXXXXXXXXXXXX
Reading application configuration data...
Beginning interaction for module default...
0% Created staging directory at: 'C:\Users\sjuarez\AppData\Local\Temp\appcfg142645335955015997.tmp'
5% Scanning for jsp files.
----
98% Uploading index definitions.

Update for module default completed successfully.
Success.
Cleaning up temporary files for module default...

Then, you can use the Application Deployment tool because the file containing the credentials is already saved on your disk.

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant