那里。 我使用Google Cloud Engine创建了一个API,该API使用Firebase进行身份验证。但是我总是打电话给这个Api,响应是:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "badRequest",
"message": "java.lang.reflect.InvocationTargetException"
}
],
"code": 400,
"message": "java.lang.reflect.InvocationTargetException"
}
}
如果我删除参数“用户用户”,我会得到200次成功回复。
这是我的代码:
@Api(
name = "crumb",
version="v2",
authenticators = {EspAuthenticator.class},
issuers = {
@ApiIssuer(
name = "firebase",
issuer = "https://securetoken.google.com/[Project-ID]",
jwksUri = "https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com")
},
issuerAudiences = {
@ApiIssuerAudience(name = "firebase", audiences = "[Project-ID]")
}
)
public class crumbAPI {
@ApiMethod(name = "getCrumbById",path = "{crumbId}",httpMethod = ApiMethod.HttpMethod.GET)
public Object getCrumbById(User user, @Named("crumbId") String crumbId) throws IOException, NotFoundException, UnauthorizedException {
if (user == null) {
throw new UnauthorizedException("Invalid credentials");
}
CrumbInfo ci = CrumbInfo.entityToCrumb(crumbId);
Bean response = new Bean();
response.setData(ci);
return response;
}
}
我用它有一个参考:Authenticating Users