使用 Google 云端点时的身份验证问题
Authentication Issue when using Google Cloud Endpoints
我目前正在使用 android studio 和 google 云端点模块以及 android studio 开发 android 应用程序。所以我试图通过 Firebase Auth 添加用户身份验证,以便我可以为我的用户提供来自不同用户的登录选项。但是,每当我尝试将身份验证代码添加到端点 class 中的 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,请转到构建/编辑库和依赖项,单击“+”并搜索 "endpoints-framework"
我目前正在使用 android studio 和 google 云端点模块以及 android studio 开发 android 应用程序。所以我试图通过 Firebase Auth 添加用户身份验证,以便我可以为我的用户提供来自不同用户的登录选项。但是,每当我尝试将身份验证代码添加到端点 class 中的 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,请转到构建/编辑库和依赖项,单击“+”并搜索 "endpoints-framework"