簡體   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