簡體   English   中英

如何將 Firebase 自定義令牌傳遞給客戶端?

[英]How to pass Firebase Custom Token to client?

我有一個項目需要使用 Facebook 和 Google 登錄,所以我選擇了 Firebase 來加快認證過程; 但是,用戶還必須能夠通過 LINE(東南亞流行的消息應用程序)登錄。

目前,我已經實現:

Line Login-> Finish Login -> Redirect to Cloud Functions -> 驗證 Line 的 Access_Token -> 從 LINE 的 ID Token 在 Firebase 中創建一個用戶 -> 從 Firebase 用戶創建自定義令牌

剩下的就是實現 signInWithCustomToken 然后從 firebase 獲取 idToken 發送到我的 api 進行授權。

現在,登錄過程應該由客戶端處理,但我不確定如何將 customToken 傳遞給客戶端(我們的后端 api 和前端客戶端是分開的)。

當我將用戶重定向到前端時,我可以在查詢參數中傳遞它,但我不確定這是否是 go 關於它的最佳方式。

我應該怎么辦?

After the user has logged in to LINE, it redirects to any link you set for it to redirect to with the url params being the authorisation code and state, so?code=xxxxxx&state=xxxxx... I decided to use cloud function to be LINE 登錄的重定向 url

If I understand correctly, instead of directly redirecting LINE to the Cloud Function, you should probably redirect to a page of your web application which, in turns, calls a Callable Cloud Function ( passing the code and state values as arguments).

此 Cloud Function 驗證令牌並在 Firebase 中創建用戶,完成后,將令牌發送回 web 應用程序的頁面。 然后,您擁有調用signInWithCustomToken()方法的所有元素。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM