久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 php 設置 firebase v3 自定義身份驗證

Setting up firebase v3 custom auth with php(使用 php 設置 firebase v3 自定義身份驗證)
本文介紹了使用 php 設置 firebase v3 自定義身份驗證的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試按照以下指南使用來自 google 的新 firebase sdk 設置自定義身份驗證:https://firebase.google.com/docs/auth/server#use_a_jwt_library
在 samble 代碼中它說:

I'm trying to set up custom auth with the new firebase sdk from google following those guidelines : https://firebase.google.com/docs/auth/server#use_a_jwt_library
In the samble code it says :

從 JSON 密鑰文件中獲取您的服務帳號的電子郵件地址和私鑰

Get your service account's email address and private key from the JSON key file

不幸的是,我不知道從哪里獲得這個 json 文件.如果我去我的 firebase 控制臺 (https://console.firebase.google.com/) 我設法下載了一個 json文件,但它不包含任何電子郵件地址和私鑰.

Unfortunately I have not idea where to get this json file. If I go to my firebase console (https://console.firebase.google.com/) I manage to donwload a json file but it does not contain any email adress and private key.

我設法在我的 google 云平臺控制臺 (http://console.conf) 中找到了一個包含電子郵件地址和私鑰的 json 文件.cloud.google.com) 進入API Manager > Credentials"菜單.令人驚訝的是,我的 firebase 應用程序顯示在那里.我將電子郵件和密鑰復制并粘貼到示例代碼中,然后出現此錯誤:

I managed to find a json file that contains an email adress and a private key in my google cloud platform console (http://console.cloud.google.com) by goind into the "API Manager > Credentials" menu. Surprisingly my firebase app was showed there. I copy and pasted the email and key into the sample code, then I got this error :

警告:openssl_sign():無法將提供的密鑰參數強制轉換為第 183 行/volume1/web/yeti/vendor/firebase/php-jwt/src/JWT.php 中的私鑰致命錯誤:未捕獲的異常DomainException"' 在/volume1/web/yeti/vendor/firebase/php-jwt/src/JWT.php:185 中帶有消息 'OpenSSL 無法簽署數據' 堆棧跟蹤:#0/volume1/web/yeti/vendor/firebase/php-jwt/src/JWT.php(154): FirebaseJWTJWT::sign('eyJ0eXAiOiJKV1Q...', NULL, 'RS256') #1/volume1/web/yeti/jwt.php(21):FirebaseJWTJWT::encode(Array, NULL, 'RS256') #2/volume1/web/yeti/jwt.php(24): create_custom_token('1234', false) #3 {main} 被拋出到/volume1/web/yeti/vendor/firebase/php-jwt/src/JWT.php 第 185 行

Warning: openssl_sign(): supplied key param cannot be coerced into a private key in /volume1/web/yeti/vendor/firebase/php-jwt/src/JWT.php on line 183 Fatal error: Uncaught exception 'DomainException' with message 'OpenSSL unable to sign data' in /volume1/web/yeti/vendor/firebase/php-jwt/src/JWT.php:185 Stack trace: #0 /volume1/web/yeti/vendor/firebase/php-jwt/src/JWT.php(154): FirebaseJWTJWT::sign('eyJ0eXAiOiJKV1Q...', NULL, 'RS256') #1 /volume1/web/yeti/jwt.php(21): FirebaseJWTJWT::encode(Array, NULL, 'RS256') #2 /volume1/web/yeti/jwt.php(24): create_custom_token('1234', false) #3 {main} thrown in /volume1/web/yeti/vendor/firebase/php-jwt/src/JWT.php on line 185

有人知道我做錯了什么嗎?

Does someone has an idea of what I'm doing wrong ?

謝謝

推薦答案

您找到解決方案了嗎?仍然遇到同樣的問題!適用于 HS256,不適用于 RS256.這是谷歌云的限制嗎?

Did you find the solution ? Still experiencing the same issue ! Works with HS256 and doesn't with RS256. Is it google cloud kind of limitation ?

非常感謝!@dbburgess

Thank you so much ! @dbburgess

問題:使用了錯誤的密鑰和電子郵件.這些應在與 Firebase 項目對應的 GCP 憑據部分中生成.

Problem: Was using the wrong key and email. These should be generated in the Google Cloud credentials section that corresponds to the Firebase project.

解決方案:

  • 轉到console.cloud.google.com".
  • 選擇相關的 Firebase 項目.
  • 然后是API 管理器"->憑據".
  • 創建憑據"->服務帳戶密鑰"-> 選擇 JSON.
  • 創建的文件將包含所需的private_key"&'client_email'.

填寫值:

$service_account_email = "autogeneratedemail@developer.gserviceaccount.com";$private_key = "-----開始私鑰----- SoneVeryVeryLongKey= -----結束私鑰----- ";$uid = 'UserToUseInFirebaseRules';$is_premium_account = $uid;

$service_account_email = "autogeneratedemail@developer.gserviceaccount.com"; $private_key = "-----BEGIN PRIVATE KEY----- SoneVeryVeryLongKey= -----END PRIVATE KEY----- "; $uid = 'UserToUseInFirebaseRules'; $is_premium_account = $uid;

您不需要更改create_custom_token"函數中的任何內容,也許可以根據您的需要更改到期日期/時間.

You shouldn't need to change anything in the "create_custom_token" function, maybe the expiration date/time according to your needs.

然后調用函數:

create_custom_token($uid, $is_premium_account);

這篇關于使用 php 設置 firebase v3 自定義身份驗證的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 国产在线高清 | 91在线精品一区二区 | 少妇淫片aaaaa毛片叫床爽 | 午夜精品在线 | 99riav国产一区二区三区 | 96久久久久久| 精品国产黄a∨片高清在线 www.一级片 国产欧美日韩综合精品一区二区 | 久久久久久亚洲精品 | 一区在线视频 | 亚洲网站在线观看 | 国产十日韩十欧美 | 麻豆一区二区三区精品视频 | 看黄在线| 全免一级毛片 | 国产成人高清 | 日韩黄色av| 日韩福利在线观看 | 精品国产精品国产偷麻豆 | av男人天堂影院 | 亚洲综合色婷婷 | 中文字幕高清在线 | 自拍偷拍亚洲一区 | 久久不卡 | 欧美国产视频 | 久久高清国产视频 | www亚洲精品| 国产一区二区高清在线 | 成人欧美一区二区三区在线观看 | 国产精品久久精品 | av国产精品 | 在线观看国产91 | 午夜精品影院 | 亚洲国产精品久久久 | 成人精品影院 | 国产精品三级 | 久久精品国产免费高清 | 亚洲综合色视频在线观看 | www.操.com| 欧美日韩在线一区二区 | 九九热在线观看 | 成人深夜福利网站 |