简体   繁体   English

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

[英]Authentication Issue when using Google Cloud Endpoints

I'm currently working on an android app using android studio and the google cloud endpoints module with android studio.我目前正在使用 android studio 和带有 android studio 的谷歌云端点模块开发一个 android 应用程序。 So I'm trying to add User authentication through the Firebase Auth so I can provide my users with sign-in options from different users.所以我试图通过 Firebase Auth 添加用户身份验证,以便我可以为我的用户提供来自不同用户的登录选项。 However whenever I try to add the authentication code to the API in my endpoint class.但是,每当我尝试将身份验证代码添加到端点类中的 API 时。 The apiIssuer and ApiissuerAudience are always unresolved. apiIssuer 和 ApiissuerAudience 始终未解决。 I've tried everything and I can't fix the issue so I'm assuming I didn't do or did something wrong to affect this part of the code.我已经尝试了一切,但我无法解决问题,所以我假设我没有做或做错了什么来影响这部分代码。

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 {


 }

You must include this library!你必须包含这个库!

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

it seems trivial but not easy to find out ... I got to try them all.这似乎微不足道,但不容易发现......我必须全部尝试。

if you use Android Studio, go to Build / Edit library and dependencies click on the "+" and search for "endpoints-framework"如果您使用 Android Studio,请转到 Build / Edit library and dependencies 单击“+”并搜索“endpoints-framework”

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

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