I use this:
- Front end with Google App Engine (GAE) javascript section
<script src="https://www.gstatic.com/firebasejs/3.6.8/firebase.js"></script>
<script>
var config = {
apiKey: "XXXXX",
authDomain: "id-aplication.firebaseapp.com",
databaseURL: "https://id-aplication.firebaseio.com",
storageBucket: "id-aplication.appspot.com",
messagingSenderId: "00000"
};
firebase.initializeApp(config);
</script>
function init(){
var apiRoot = "//id-aplication.appspot.com/_ah/api";
gapi.client.load('Api', "v1", callback, apiRoot);
}
function createUserFirebase(){
var user = firebase.auth().currentUser;
var request = gapi.client.Api.createUserFirebase(user);
request.execute(callBackResponse);
}
function callback(){
btn = document.getElementById("input_create_user_firebase");
btn.onclick=function(){createUserFirebase();};
btn.value="Click me for Create User Firebase";
}
Run code- BackEnd with Google Cloud EndPoint
@Api(name = "Api",
version = "v1",
namespace =
@ApiNamespace(
ownerDomain = "api.example.com",
ownerName = "api.example.com", packagePath = "" ),
issuers = {
@ApiIssuer(
name = "firebase",
issuer = "https://securetoken.google.com/id-aplication",
jwksUri = "https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com")
},
issuerAudiences = {
@ApiIssuerAudience(name = "firebase", audiences = "id-aplication")}
)
public class SharedRoadApi {
@ApiMethod(
name = "firebase_user",
httpMethod = ApiMethod.HttpMethod.GET,
authenticators = {EspAuthenticator.class},
issuerAudiences = {@ApiIssuerAudience(name = "firebase", audiences = {"id-aplication"})}
)
public Email firebase_user(User user) throws UnauthorizedException {
if (user == null) {
throw new UnauthorizedException("Invalid credentials");
}
Email response = new Email();
response.setEmail(user.getEmail());
return response;
}
}
Run code- Authentication with Firebase
Steps:
- Firebase Authenticated Login
- Call the java method in Google Cloud EndPoint and this will not give messae "Invalid credentials", it means authenticate
- But even if you log in, report an error,
authenticate com.google.api.server.spi.auth.EspAuthenticator: Authentication failed: com.google.api.auth.UnauthenticatedException: There is no authentication token in the HTTP request (EspAuthenticator.java:86)
I would appreciate if someone would tell me what to do specifically or add, thank you very much.