简体   繁体   English

使用Google App Engine中的Firebase进行Google EndPoint身份验证 - HTTP请求中不包含身份验证令牌

[英]Google EndPoint Authentication with Firebase from Google App Engine - No auth token is contained in the HTTP request

I am using this : 我用这个:

  • Front End with Google App Engine(GAE) the javascript section 前端与谷歌应用引擎(GAE)的JavaScript部分

 <script src="https://www.gstatic.com/firebasejs/3.6.8/firebase.js"></script> <script> // Initialize Firebase 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"; } 

  • BackEnd with Google Cloud EndPoint BackEnd与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; } } 

  • Authentication with Firebase 使用Firebase进行身份验证

The steps are: 步骤是:

  • Login with Firebase authentication 使用Firebase身份验证登录
  • Call the java method in the Google Cloud EndPoint, and this dont give the messae "Invalid credentials", this mean that authenticate 在Google Cloud EndPoint中调用java方法,这不会给Messae“无效凭据”,这意味着验证
  • But even if you login the method give error, 但即使你登录该方法给出错误,

com.google.api.server.spi.auth.EspAuthenticator authenticate: Authentication failed: com.google.api.auth.UnauthenticatedException: No auth token is contained in the HTTP request (EspAuthenticator.java:86) com.google.api.server.spi.auth.EspAuthenticator authenticate:身份验证失败:com.google.api.auth.UnauthenticatedException:HTTP请求中不包含身份验证令牌(EspAuthenticator.java:86)

I would appreciate it if anyone can tell me what I should do specifically or add, thank you very much. 如果有人能告诉我我应该做什么或添加,我将不胜感激,非常感谢。

You need to authenticate the client: the endpoints server is expecting authentication from the client, but receives none. 您需要对客户端进行身份验证:端点服务器期望从客户端进行身份验证,但不会收到任何身份验证。 More fine-grained information is to be found in the Using Endpoints in a JavaScript Client document, specifically in the subsection “Adding authentication support with OAuth 2.0”. 可以在JavaScript客户端文档中的“ 使用端点”中找到更细粒度的信息,特别是在“使用OAuth 2.0添加身份验证支持”小节中。

any reference to gapi.client.Api.createUserFirebase(user)? 对gapi.client.Api.createUserFirebase(用户)的任何引用? I couldn't find any document or code implementation of this method. 我找不到此方法的任何文档或代码实现。

BTW, since I don't have enough reputations to add a comment, we will use this thread to collect more details to help troubleshoot this issue. 顺便说一句,由于我没有足够的声誉来添加评论,我们将使用此线程收集更多详细信息以帮助解决此问题。 We will replace this with a real answer soon. 我们很快就会用一个真正的答案取而代之。

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

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