0

What I'm trying to do is to avoid hardcoding the parameters and avoid using a java configuration file (with constants).

The sample provided by google uses in fact constants and all their repositories the same, this way:

@Api(
    version = "v1",
    description = "Sample API",
    scopes = {"ss0", "ss1"},
    audiences = {"aa0", "aa1"},
    clientIds = {"cc0", "cc1"},
    defaultVersion = AnnotationBoolean.TRUE
)

However my problem is that the code is part of an open source project and I'd rather not put sensitive data in it :) nor having to leave it blank.

Usually the solution is always to use a configuration file (*.properties), is this possible with google cloud endpoints? is there a way to do it or a clean alternative?

tizio
  • 21
  • 3

1 Answers1

0

As indicated here [1] App Engine allows apps to read local files. All you have to do is place your config file in the root (or subdirectories) of your code path and deploy.

An example of this functionality is when authenticating with OAuth through Services Accounts [2] as a file is needed to retrive credential's key.

After that you only have to care about parsing the file. I usually use JSON formatted files [3].

[1] https://cloud.google.com/appengine/docs/java/#Java_The_sandbox

[2] https://cloud.google.com/bigquery/authorization#service-accounts-server

[3] How to parse JSON in Java

Community
  • 1
  • 1
Layo
  • 677
  • 6
  • 16
  • Maybe it's similar but in my case I'm using the API Endpoint for the cloud service, to provide an interface to communicate from an android app to the cloud service. More specifically: https://cloud.google.com/appengine/docs/java/endpoints/annotations – tizio Feb 27 '15 at 13:40
  • Your code belongs to your backend API that you still need to deploy to App Engine like any other regular app, you just have to add the config file along with the API files and deploy it. You will be able to open the file from there. – Layo Feb 28 '15 at 06:51