Google App Engine Remote API Service Account Credential error - google-app-engine

I am currently using remote api for google app engine to connect to a datastore from another GAE project.
Below is my code:
RemoteApiOptions options;
options = new RemoteApiOptions().server("project_id.appspot.com",443).useServiceAccountCredential("project#project-168016.iam.gserviceaccount.com","EPHIMS-cbe10d4a5105.json");
RemoteApiInstaller installer = new RemoteApiInstaller();
installer.install(options);
When I run my application, I get the error below:
java.lang.RuntimeException: Failed to build service account credential.
Caused by: java.io.FileNotFoundException: EPHIMS-cbe10d4a5105.json (The system cannot find the file specified)
at java.io.FileInputStream.open0(Native Method)
Does anyone know how to fix this? - I have created an environment variable and set it to the path where the .json file is, this still does not work.

Related

deploy scala sbt to google app engine

While importing my scala sbt project to intellij i get the following error
Error while importing SBT project: ...
[info] Loading project definition from /home/dnilesh/Desktop/app-engine/sbt-appengine-demo-master/project
java.lang.RuntimeException: You need to set APPENGINE_SDK_HOME
at scala.sys.package$.error(package.scala:27)
at sbtappengine.Plugin$AppEngine$.buildAppengineSdkPath(AppenginePlugin.scala:103)
at sbtappengine.Plugin$$anonfun$baseAppengineSettings$33.apply(AppenginePlugin.scala:219)
at sbtappengine.Plugin$$anonfun$baseAppengineSettings$33.apply(AppenginePlugin.scala:219)
at sbt.Init$Value$$anonfun$apply$13.apply(Settings.scala:604)
at sbt.EvaluateSettings$$anonfun$sbt$EvaluateSettings$$constant$1.apply(INode.scala:163)
at sbt.EvaluateSettings$$anonfun$sbt$EvaluateSettings$$constant$1.apply(INode.scala:163)
at sbt.EvaluateSettings$MixedNode.evaluate0(INode.scala:175)
at sbt.EvaluateSettings$INode.evaluate(INode.scala:135)
at sbt.EvaluateSettings$$anonfun$sbt$EvaluateSettings$$submitEvaluate$1.apply$mcV$sp(INode.scala:69)
at sbt.EvaluateSettings.sbt$EvaluateSettings$$run0(INode.scala:78)
at sbt.EvaluateSettings$$anon$3.run(INode.scala:74)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
[error] You need to set APPENGINE_SDK_HOME
[error] Use 'last' for the full log.
Invalid response.
See complete log in file:/home/dnilesh/.IdeaIC2017.2/system/log/sbt.last.log Consult IDE log for more details (Help | Show Log)
and while deploying same app to google app engine from terminal i get the same error after that, In terminal i set APPENGINE_SDK_HOME to my google cloud installation directory /usr/lib/google-cloud-sdk/platform/google_appengine/. then i get the following error.
So how can i set APPENGINE_SDK_HOME and to which path so that sbt appengineDeploy command will work.
root#dnilesh-pc:/home/dnilesh/Desktop/app-engine/sbt-appengine-demo-master# sbt appengineDeploy
[info] Loading project definition from /home/dnilesh/Desktop/app-engine/sbt-appengine-demo-master/project
java.lang.RuntimeException: not found appengine api jar.
at scala.sys.package$.error(package.scala:27)
at sbtappengine.Plugin$AppEngine$.buildSdkVersion(AppenginePlugin.scala:114)
at sbtappengine.Plugin$$anonfun$baseAppengineSettings$32.apply(AppenginePlugin.scala:218)
at sbtappengine.Plugin$$anonfun$baseAppengineSettings$32.apply(AppenginePlugin.scala:218)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.EvaluateSettings$MixedNode.evaluate0(INode.scala:175)
at sbt.EvaluateSettings$INode.evaluate(INode.scala:135)
at sbt.EvaluateSettings$$anonfun$sbt$EvaluateSettings$$submitEvaluate$1.apply$mcV$sp(INode.scala:69)
at sbt.EvaluateSettings.sbt$EvaluateSettings$$run0(INode.scala:78)
at sbt.EvaluateSettings$$anon$3.run(INode.scala:74)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[error] not found appengine api jar.
[error] Use 'last' for the full log.
Steps I did to sort out this issue:
Download the App Engine SDK for Java:
Google App Engine
Direct Download Link
Extract it in your computer regardless your GCloud installed path.
set APPENGINE_SDK_HOME :
export APPENGINE_SDK_HOME= /PATH/TO/SDK/appengine-java-sdk-1.9.54
Download Sample Scala sbt application.
Github Sample Scala App
run sbt appengineDeploy command to run app. change project id to your project id on google cloud. Steps before running app
Notes:
You cannot install third party databases like mongodb on gae.
gae does not support akka framework.
gae does not support multithreading.

Android emulator does not gain access to authorized api

The Android Emulator (Nexus) in Android Studio does not gain access to authorized api (Endpoints from Google cloud App Engine).
The following code works fine with a physical device but not with the emulator:
credential = GoogleAccountCredential.usingAudience(context,
"server:client_id:" + "xyz-xyz.apps.googleusercontent.com");
credential.setSelectedAccountName("xyz#gmail.com");
builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(), new
AndroidJsonFactory(), credential).setRootUrl("https://babydo-xyz.appspot" +
".com/_ah/api/").setApplicationName("BackendTest");
The following error shows the Android Monitor:
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: ch.appfactory.kusi.backendtest, PID: 8074
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
Caused by: java.lang.IllegalArgumentException: the name must not be empty: null
at android.accounts.Account.<init>(Account.java:48)
at com.google.android.gms.auth.zzd.getToken(Unknown Source)
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
The App Engine console shows no server error.
Interestingly, the emulator has access to the api and work fine, when no authentication is implemented, according to the following Code:
builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(), new
AndroidJsonFactory(), null).setRootUrl("https://babydo-xyz.appspot" +
".com/_ah/api/");
Does anyone know what to consider, when the emulator make authenticated calls?
Thanks for answering

Deploying an app on Google App Engine path to certificate not provided error

For the past few days I have been trying to trace the source of the error shown in the blockquote in trying to deploy an app to google app engine on a windows machine using the command:
> gcloud preview app deploy app.yaml
Beginning deployment... Verifying that Managed VMs are enabled and
ready.
Traceback (most recent call last): ...
File "C:\Program Files\Google\Cloud
SDK\google-cloud-sdk\bin.../lib\docker\docker\tls.py", line 46, in
init
'Path to a certificate and key files must be provided'
TLSParameterError: Path to a certificate and key files must be
provided through the client_config param. TLS configurations should
map the Docker CLI client configurations.
Does anyone have any idea on how to solve this issue?
FYI: I have already set the environment variables DOCKER_CERT_PATH, DOCKER_TLS_VERIFY and DOCKER_HOST as set by Docker.

Remote implementation for app_identity_service.GetAccessToken failed at GAE PHP dev

Google App Engine SDK for PHP (at local environment) returns error on any try to use Google Cloud Storage. Error message is:
Fatal error: Uncaught exception 'google\appengine\runtime\RPCFailedError' with message 'Remote implementation for app_identity_service.GetAccessToken failed' in /media/data/home/vladimir/setup/gae/google_appengine/php/sdk/google/appengine/runtime/RemoteApiProxy.php on line 92
It exactly repeats the problem described here:
App engine update breaks CloudStorage in dev php env
Test code from the question above shows the same result.
I tried App Engine SDK for PHP versions 1.9.19, 1.9.20, 1.9.21 without success.
On Win10 this issue can be solved by generating an application-default credentials file:
D:\Workspace\Sourcecode>gcloud auth application-default login
Credentials saved to file: [C:\Users\Otje\AppData\Roaming\gcloud\application_default_credentials.json]
And then setting the environment in commandline:
D:\Workspace\Sourcecode>SET GOOGLE_APPLICATION_DEFAULT=C:\Users\Otje\AppData\Roaming\gcloud\application_default_credentials.json
Seems to me GAE on local just outputs limited error information when it can't find the right credentials to succesfully connect to remote endpoint.
It seems that it was GAE's server side issue. They fixed it. I discovered that it started to work as expected today without any changes applied by me.

Cannot access worklight server appcenter

Hi i have installed worklight server. By using configuration tool i deployed a war from a dummy project that i created. I also provided all information required without any errors. I created defaultServer (websphere) and i started it (server start command). I can access console: mydomain:9080/mycontextroot/console
but i cant access app center
mydomain:9080/mycontextroot/appcenterconsole or /applicationcenter
the error i get is:
Exception thrown by application class 'com.worklight.core.auth.impl.AuthenticationFilter.doFilter:233'
java.lang.RuntimeException: java.io.FileNotFoundException: SRVE0190E: File not found: /applicationcenter
at com.worklight.core.auth.impl.AuthenticationFilter.doFilter(AuthenticationFilter.java:233)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:194)
at [internal classes]
Caused by: java.io.FileNotFoundException: SRVE0190E: File not found: /applicationcenter
at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:496)
at [internal classes]
at com.worklight.core.auth.impl.AuthenticationFilter$1.execute(AuthenticationFilter.java:191)
at com.worklight.core.auth.impl.AuthenticationServiceBean.accessResource(AuthenticationServiceBean.java:76)
at com.worklight.core.auth.impl.AuthenticationFilter.doFilter(AuthenticationFilter.java:195)
... 2 more
any help?
The App Center is configured separately from deploying a WAR from Studio. See: http://pic.dhe.ibm.com/infocenter/wrklight/v6r1m0/topic/com.ibm.worklight.installconfig.doc/appcenter/c_configuration_of_the_applicati.html
If you decided to include the application center as part of the Worklight Server installaltion inside of Installation Manager you may not have the correct context root or you may have not correctly configured it.
In Worklight 6.1 the application center will be installed to a
http://"server address":"port"/appcenterconsole
Configuring the Application Center after installation:
https://pic.dhe.ibm.com/infocenter/wrklight/v6r1m0/topic/com.ibm.worklight.installconfig.doc/appcenter/c_configuration_of_the_applicati.html
You can also check your server configuration as well as server file structure to make sure the application center war is included and you have the correct context root. Finally if you do not have the application center installed at all you can install it manually following these instructions:
https://pic.dhe.ibm.com/infocenter/wrklight/v6r1m0/index.jsp?topic=%2Fcom.ibm.worklight.installconfig.doc%2Fadmin%2Fc_installation.html

Resources