kreait / laravel-firebase

A Laravel package for the Firebase PHP Admin SDK
https://github.com/kreait/firebase-php
MIT License
992 stars 163 forks source link

`signInWithFacebookAccessToken`'s result is returning null `firebaseUserId` #117

Closed arifszn closed 2 years ago

arifszn commented 2 years ago

I have a user on firebase having email x@gmail.com and provider google. Now, when I use signInWithFacebookAccessToken with facebook account having the same mail, I am getting null firebaseUserId.

The rest of the information are correct and the uid is showing elsewhere in data->localId.

jeromegamez commented 2 years ago

Unfortunately, you didn't share which version of the package and library you are using and no code that I can try to reproduce the problem with 😭, so I'll have to do a bit of guesswork here.

Can you confirm that the ID you expected is present in the data->localId property of the returned SignInResult object and the firebaseUserId is null?

If you're indeed talking about the properties, please note that you need to use the firebaseUserId() method to access the property.

Otherwise, please provide more information so that I can try to reproduce the problem 🙏 .

arifszn commented 2 years ago

@jeromegamez, Sorry I missed out on the information.

The code I am using:

$signInResult = $this->auth->signInWithFacebookAccessToken($accessToken);
$firebaseUser = $this->auth->getUser($signInResult->firebaseUserId());

This is dumped $signInResult: image image

This is dumped $signInResult->firebaseUserId(): image

Yes, the data->localId has the same uid which is in the firebase console. image

The version I am using:

"name": "kreait/laravel-firebase",
"version": "3.2.0",

Laravel version:

"name": "laravel/framework",
"version": "v8.70.2",

PHP version: 8

jeromegamez commented 2 years ago

Thank you for providing the additional info! I was able to confirm the issue and have added support for the localId field in https://github.com/kreait/firebase-php/commit/ff7c396cb143e298c72f1a19967c0986b4821cfd (5.x) and https://github.com/kreait/firebase-php/commit/35ec1919c6ed8d4f88134e4fd6953d9f044af836 (6.x), will create a new release shortly and notify you here.

jeromegamez commented 2 years ago

Released with https://github.com/kreait/firebase-php/releases/tag/6.0.1 and https://github.com/kreait/firebase-php/releases/tag/5.26.1

You should be able to fetch the update with a composer update -W

Thanks again for raising the issue!