我想允许用户使用firebase通过GitHub和电子邮件/密码登录/注册。
在服务器端,我使用firebase_admin SDK(电子邮件/密码)实现了它:
/* Create Context-Engine */
void *ctx = zmq_ctx_new (); assert (ctx);
/* Create ZMQ_STREAM socket */
void *socket = zmq_socket (ctx, ZMQ_STREAM); assert (socket);
int rc = zmq_bind (socket, "tcp://*:8080"); assert (rc == 0);
/* Data structure to hold the ZMQ_STREAM ID */
uint8_t id [256];
size_t id_size = 256;
/* Data structure to hold the ZMQ_STREAM received data */
uint8_t raw [256];
size_t raw_size = 256;
while (1) {
/* Get HTTP request; ID frame and then request */
id_size = zmq_recv (socket, id, 256, 0); assert (id_size > 0);
do {
raw_size = zmq_recv (socket, raw, 256, 0); assert (raw_size >= 0);
} while (raw_size == 256);
/* Prepares the response */
char http_response [] =
"HTTP/1.0 200 OK\r\n"
"Content-Type: text/plain\r\n"
"\r\n"
"Hello, World!";
/* Sends the ID frame followed by the response */
zmq_send (socket, id, id_size, ZMQ_SNDMORE);
zmq_send (socket, http_response, strlen (http_response), 0);
/* Closes the connection by sending the ID frame followed by a zero response */
zmq_send (socket, id, id_size, ZMQ_SNDMORE);
zmq_send (socket, 0, 0, 0);
}
zmq_close (socket); zmq_ctx_destroy (ctx); /* Clean Close Sockets / Terminate Context */
它工作正常,但是我想通过GitHub注册时获得相同的结果。也就是说,我希望能够设置自己的uid。请注意,我希望代码主要位于服务器端。我希望用户单击相同的按钮登录或注册。
我实际上是使用Firebase文档中的下一个代码通过服务器端的自定义uid来对用户进行身份验证的:
user = auth.create_user(
uid=submission["id"], // customized id
email=submission["email"],
password=submission["pass"],
display_name=submission["name"] + " " + submission["lastName"])
但是身份验证结束后,我不知道如何登录。登录代码是否应该在客户端?
答案 0 :(得分:1)
登录总是在客户端上进行,而不是在服务器上进行。 Firebase Admin SDK所能做的就是创建,删除和修改帐户。最终用户登录客户端应用程序时必须提供该帐户的凭据。