0
votes

My question is already answered here: apiKeyRequired in google cloud endpoint not getting resolved

But it didn't work for me.

I still have the issue, that the IDE is not able to resolve the apiKeyRequired attribute. I'm using the endpoints-framework 2.+.

@Api(
        name = "api",
        version = "v1",
        apiKeyRequired = AnnotationBoolean.TRUE,
        namespace = @ApiNamespace(
                ownerDomain = "backendDomain.myapplication.test.example.com",
                ownerName = "backendName.myapplication.test.example.com",
                packagePath = ""
        )
)
public class MyEndpoint {
...

build.gradle

...
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

dependencies {
   appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.54'

   compile 'javax.servlet:servlet-api:2.5'

   compile 'com.google.appengine:appengine-endpoints:1.9.54'
   compile 'com.google.appengine:appengine-endpoints-deps:1.9.54'

   compile 'com.google.endpoints:endpoints-framework:2.0.7'
}
...
1

1 Answers

0
votes

Got it!! After trying to solve the problem for hours! The solution came direct after posting this question.

The problem were the used dependencies. This two dependencies in the build.gradle files caused the problem:

compile 'com.google.appengine:appengine-endpoints:1.9.54'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.54'

I replaced them with this two new dependecies:

compile 'com.google.endpoints:endpoints-management-control-appengine:1.0.3'
compile 'com.google.endpoints:endpoints-framework-auth:1.0.3'

build.gradle (updated):

...
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

dependencies {
    appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.54'

    compile 'javax.servlet:servlet-api:2.5'

    compile 'com.google.endpoints:endpoints-framework:2.0.7'
    compile 'com.google.endpoints:endpoints-management-control-appengine:1.0.3'
    compile 'com.google.endpoints:endpoints-framework-auth:1.0.3'
}
...