Firebase用户对象在Localhost上为null

时间:2019-02-26 06:22:41

标签: firebase google-app-engine

我在本地主机上的Firebase令牌有问题。

@Api(name = "account",
 version = "v1",
 authenticators =  {EspAuthenticator.class},
 issuers =        {@ApiIssuer(  name = "firebase",
                                issuer =     "https://securetoken.google.com/PROJECTID",
                                jwksUri =     "https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com")},
 issuerAudiences = {@ApiIssuerAudience(name = "firebase", audiences =     {"PROJECTID"})})             
public class AccountService {

    @ApiMethod(path="user/{id}", httpMethod = "get")
    public User GetUser(@Named("id") String id, User user) throws UnauthorizedException,BadRequestException,NotFoundException    
    {
    }
}

尤其是应该返回com.google.api.server.spi.auth.common.User的User用户。 当我在Google云端上运行此代码时,我会返回正确的结果。

当我在localhost上运行它时,它总是返回null。

我无法弄清楚我在做什么错,因为默认情况下,使用Firebase时Localhost应该可以,如下所示。为什么在本地主机上看不到用户对象?

enter image description here

1 个答案:

答案 0 :(得分:0)

该问题与此现有问题有关。 Google Cloud Endpoints + Firebase Auth: method_info is not set

尚未部署openapi文档,因此未包括用户。 调用以下命令可以解决此问题:-

gcloud endpoints services deploy target/openapi-docs/openapi.json