Android Google Cloud Endpoints v2,带firebase和改型
我想用用户身份验证来保护我的API方法。最适合Android应用的似乎是firebase身份验证,我正在使用它。 现在,我如何使用经过身份验证的firebase用户进行改装甚至curl来调用我的API方法 我遵循了中的示例,并添加了以下API方法:Android Google Cloud Endpoints v2,带firebase和改型,android,retrofit2,google-cloud-endpoints,Android,Retrofit2,Google Cloud Endpoints,我想用用户身份验证来保护我的API方法。最适合Android应用的似乎是firebase身份验证,我正在使用它。 现在,我如何使用经过身份验证的firebase用户进行改装甚至curl来调用我的API方法 我遵循了中的示例,并添加了以下API方法: @ApiMethod( path = "firebase_user", httpMethod = ApiMethod.HttpMethod.GET, authenticators
@ApiMethod(
path = "firebase_user",
httpMethod = ApiMethod.HttpMethod.GET,
authenticators = {EspAuthenticator.class},
issuerAudiences = {@ApiIssuerAudience(name = "firebase", audiences = {PROJECT_ID})}
)
public Translation getUserEmailFirebase(User user) throws UnauthorizedException {
if (user == null) {
throw new UnauthorizedException("Invalid credentials");
}
return new Translation();
}
现在,应该如何称呼它?我试过了
curl \
-H "Authorization: my-firebase-user-token-id" \
https://my-api-link.appspot.com/_ah/api/something/v1/firebase_user
但我收到
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Invalid credentials"
}
],
"code": 401,
"message": "Invalid credentials"
}
}
使用改装我不得不添加
@标题(“授权”)字符串令牌
到api方法param,并在代码中
“持票人”+代币
作为象征。来吧。auth头应该是什么样子?他们在文档中的任何地方都没有提到,android的API库在alpha中。。。