Search code examples
javagoogle-app-enginegoogle-cloud-endpoints

Add clientIds dynamically to API annotation


I have a java Appengine application which uses google endpoints frameworks.

I have a set of client ids that consume my api key and those client ids may change in some intervals due to new applications coming up to consume my api.

I need to maintain an array of client ids so that no other user can access my api other than present in my list.

Due to which i need to re-deploy my code to cloud platform each time i add a client id.

"@Api" being an annotation i cannot assign value to it dynamically because annotations are considered at compile time.

So is there anyway that i can add client ids without re-deploying the code again and again?


Solution

  • If you need dynamic client IDs, you need to write a custom Authenticator, which you will put in your @Api annotation. You can base it on the existing authenticators. Then, have your authenticator check a dynamic source (e.g. Cloud SQL), rather than the annotation value.