繁体   English   中英

使用 Google Cloud Endpoints 时的身份验证问题

[英]Authentication Issue when using Google Cloud Endpoints

我目前正在使用 android studio 和带有 android studio 的谷歌云端点模块开发一个 android 应用程序。 所以我试图通过 Firebase Auth 添加用户身份验证,以便我可以为我的用户提供来自不同用户的登录选项。 但是,每当我尝试将身份验证代码添加到端点类中的 API 时。 apiIssuer 和 ApiissuerAudience 始终未解决。 我已经尝试了一切,但我无法解决问题,所以我假设我没有做或做错了什么来影响这部分代码。

package com.example.Kendrickod.myapplication.backend;

import com.example.Kendrickod.myapplication.backend.domain.Profile;
import com.google.api.server.spi.auth.EspAuthenticator;
import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.ApiMethod;
import com.google.api.server.spi.config.ApiNamespace;
import com.google.api.server.spi.config.Named;

/**
* Defines event APIs.
*/


/** An endpoint class we are exposing */
@Api(name = "event",
    version = "v1",
    namespace = @ApiNamespace(ownerDomain =
     "backend.myapplication.Kendrickod.example.com",
            ownerName = "backend.myapplication.Kendrickod.example.com",
            packagePath = ""),
    authenticators = {EspAuthenticator.class},
    issuers = {
            @ApiIssuer(
                    name = "firebase",
                    issuer = "https://securetoken.google.com/YOUR-PROJECT-ID",
                    jwksUri = "https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com")
    },
    issuerAudiences = {
            @ApiIssuerAudience(name = "firebase", audiences = "YOUR-PROJECT-ID")
    },
    clientIds = {Constants.WEB_CLIENT_ID, Constants.ANDROID_CLIENT_ID, Constants.IOS_CLIENT_ID},
    audiences = {Constants.ANDROID_AUDIENCE})

 public class EventApi {


 }

你必须包含这个库!

com.google.endpoints:endpoints-framework-auth:1.0.2

这似乎微不足道,但不容易发现......我必须全部尝试。

如果您使用 Android Studio,请转到 Build / Edit library and dependencies 单击“+”并搜索“endpoints-framework”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM