久久久久久久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)
主站蜘蛛池模板: 日韩中文在线视频 | 在线看片国产精品 | jlzzjlzz欧美大全 | 夜夜操天天干 | 奇米超碰 | 久久国内精品 | 久草免费在线视频 | 成人日b视频 | 成人午夜毛片 | 天天曰天天曰 | 欧美在线a| 精品国产一区二区国模嫣然 | 欧美久久久久久久 | 国产福利视频 | 国产精品久久久久久久久免费桃花 | 成人av一区二区亚洲精 | 神马久久香蕉 | 黄色网址大全在线观看 | 亚洲不卡在线观看 | 中文字幕在线观看视频网站 | 亚洲网站观看 | 超碰人人艹 | 欧美日韩久久 | 国产精品视频一二三区 | 欧美一区二区三区在线播放 | 国产精品无码久久久久 | 91成人免费看片 | 欧美日韩精品久久久免费观看 | 国产精品国产三级国产aⅴ无密码 | 久久久久久久久久久久久久久久久久久久 | 99精品视频一区二区三区 | 久久激情av| 成人在线精品 | 亚洲欧美日韩成人在线 | 国产yw851.c免费观看网站 | 亚洲精品久久久蜜桃 | 精品欧美一区二区在线观看欧美熟 | 午夜精品久久久久久久久久久久 | 成年视频在线观看 | 免费一区 | 亚洲欧美视频一区 |