Setting up firebase v3 custom auth with php

后端 未结 5 717
囚心锁ツ
囚心锁ツ 2020-12-31 21:40

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 t

5条回答
  •  臣服心动
    2020-12-31 22:04

    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 ?


    Thank you so much ! @dbburgess

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

    Solution:

    • Go to 'console.cloud.google.com'.
    • Select the related Firebase project.
    • Then 'API Manager' -> 'Credentials'.
    • 'Create Credentials' -> 'Service Account Key' -> Choose JSON.
    • The created file will contain the needed 'private_key' & 'client_email'.

    Fill the values:

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

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

    Then call the function:

    create_custom_token($uid, $is_premium_account);
    

提交回复
热议问题