I'm currently working on an android app using android studio and the google cloud endpoints module with android studio. 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. However whenever I try to add the authentication code to the API in my endpoint class. The apiIssuer and ApiissuerAudience are always unresolved. 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/[email protected]")
},
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"