Firehost用户对象在Localhost上为null

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Firehost用户对象在Localhost上为null相关的知识,希望对你有一定的参考价值。

我在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上看到用户对象?

enter image description here

答案

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

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

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

以上是关于Firehost用户对象在Localhost上为null的主要内容,如果未能解决你的问题,请参考以下文章

在 Mac 上为虚拟机设置 localhost

在Windows上为localhost创建自签名证书

Swagger UI 页面在 localhost SSL Url 上为空白

在 Express 上为子域使用 VHOST

如何在 Ubuntu 上为 Apache2 配置子域?

我正在尝试使用 json-server、Node 和 Express 在 localhost 上为我的 Angular 应用程序模拟 RESTFUL API。随之而来的 CORS 问题