google-app-engine - 来自 Google App Engine 的使用 Firebase 的 Google EndPoint 身份验证 - HTTP 请求中不包含任何身份验证 token

标签 google-app-engine authentication firebase-authentication google-cloud-endpoints firebase-security

我正在使用这个:

  • 使用 Google App Engine(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";
        
        	
        }

  • 使用 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;
		  }
	  }

  • 使用 Firebase 进行身份验证

步骤是:

  • 使用 Firebase 身份验证登录
  • 调用 Google Cloud EndPoint 中的 java 方法,这不会给出消息“无效凭据”,这意味着进行身份验证
  • 但是即使你登录方法报错,

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)

如果有人能告诉我具体应该做什么或补充什么,我将不胜感激。

最佳答案

对 gapi.client.Api.createUserFirebase(user) 的任何引用?我找不到此方法的任何文档或代码实现。

顺便说一句,由于我没有足够的声誉来添加评论,我们将使用此线程来收集更多详细信息以帮助解决此问题。我们很快就会用真实的答案替换它。

关于google-app-engine - 来自 Google App Engine 的使用 Firebase 的 Google EndPoint 身份验证 - HTTP 请求中不包含任何身份验证 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42196170/

相关文章:

使用 Golang 的 HTTP 基本身份验证

google-app-engine -/_ah/start 在 AppEngine 上的 Go 中从未被调用

google-app-engine - 连接 GWT 和 PostgreSQL

python - 如何向汤森路透 Open Calais API 提交 Python 请求

c# - C#中的 retrofit 和OAuth认证,为什么要再次使用Http

c# - ASP.NET Core 2.0 使用两个数据库,一个用于身份验证,一个用于数据

c# - 如何在Unity中调用Firebase电子邮件登录任务中的函数?

java - PhoneAuthProvider.OnVerificationStateChangedCallbacks 没有被解雇

Android app bundle 上传会在 Firebase 身份验证中创建奇怪的帐户 (<characters>.<5 digits>@gmail.com)

java - Google Cloud Storage 通过 App Engine 定价