首页 > 解决方案 > Firebase 用户对象在 Localhost 上为空

问题描述

我在 localhost 上遇到 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 的用户用户。当我在谷歌云上运行它时,我得到了正确的结果。

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

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

在此处输入图像描述

标签: firebasegoogle-app-engine

解决方案


该问题与此现有问题有关。 Google Cloud Endpoints + Firebase 身份验证:未设置 method_info

openapi 文档尚未部署,因此未包含用户。调用以下解决了这个问题: -

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

推荐阅读