[英]Authentication of HTTP request from an Android App to A Google Cloud Engine App
[英]Google EndPoint Authentication with Firebase from Google App Engine - No auth token is contained in the HTTP request
我用这个:
<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"; }
@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; } }
步骤是:
com.google.api.server.spi.auth.EspAuthenticator authenticate:身份验证失败:com.google.api.auth.UnauthenticatedException:HTTP请求中不包含身份验证令牌(EspAuthenticator.java:86)
如果有人能告诉我我应该做什么或添加,我将不胜感激,非常感谢。
您需要对客户端进行身份验证:端点服务器期望从客户端进行身份验证,但不会收到任何身份验证。 可以在JavaScript客户端文档中的“ 使用端点”中找到更细粒度的信息,特别是在“使用OAuth 2.0添加身份验证支持”小节中。
对gapi.client.Api.createUserFirebase(用户)的任何引用? 我找不到此方法的任何文档或代码实现。
顺便说一句,由于我没有足够的声誉来添加评论,我们将使用此线程收集更多详细信息以帮助解决此问题。 我们很快就会用一个真正的答案取而代之。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.