【问题标题】:Authentication Issue when using Google Cloud Endpoints使用 Google Cloud Endpoints 时的身份验证问题
【发布时间】:2017-03-09 05:57:59
【问题描述】:

我目前正在使用 android studio 和 google cloud endpoints 模块与 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 {


 }

【问题讨论】:

    标签: google-app-engine android-studio firebase-authentication google-cloud-endpoints


    【解决方案1】:

    你必须包含这个库!

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

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

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

    【讨论】:

    • 对不起,您还必须导入 com.google.endpoints:endpoints-framework 库,并注意将它们放在所有其他库之前...仅此而已!
    • 谢谢!这使它工作。我觉得这与我的图书馆有关。
    猜你喜欢
    • 2017-07-06
    • 1970-01-01
    • 2020-06-10
    • 2014-10-11
    • 2018-12-29
    • 1970-01-01
    • 2016-02-03
    • 1970-01-01
    • 2015-12-07
    相关资源
    最近更新 更多