我们正在使用App Engine和Firebase,但有一个小问题。我们想在API批注中使用环境变量,但遇到了障碍。
package com.myapp.services;
import com.google.api.server.spi.auth.EspAuthenticator;
import com.google.api.server.spi.auth.common.User;
import com.google.api.server.spi.config.*;
@Api(
name = "contacts",
version = "v1",
authenticators = {EspAuthenticator.class},
issuers = {@ApiIssuer(name = "firebase",
issuer = "https://securetoken.google.com/<<PROJECT_NAME_GOES_HERE>>",
jwksUri = "https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com")},
issuerAudiences = {@ApiIssuerAudience(name = "firebase", audiences = "<<PROJECT_NAME_GOES_HERE>>")},
authLevel = AuthLevel.REQUIRED
)
public class ContactService {
@ApiMethod(path = "create", httpMethod = "post")
public Long CreateContact(Contact contact, User user) {
// Create the record
return contact.id;
}
}
我们如何根据环境更新发行人和受众的价值?我们可以使用Guice将环境传递到方法中,但是不能注入注释中。
我们只想在部署时更新<<<PROJECT_NAME_GOES_HERE>>>
。