@@ -144,10 +144,53 @@ Get information about a specific user
144144 $user = $auth->getUser('some-uid');
145145 $user = $auth->getUserByEmail('user@example.com');
146146 $user = $auth->getUserByPhoneNumber('+49-123-456789');
147+ // For `getUserByProviderUid()` please see the section below.
148+ $user = $auth->getUserByProviderUid('google.com', 'google-uid');
147149 } catch (\Kreait\Firebase\Exception\Auth\UserNotFound $e) {
148150 echo $e->getMessage();
149151 }
150152
153+ ***************************************************
154+ Get information about a user by federated provider
155+ ***************************************************
156+
157+ You can retrieve a user by their federated identity provider UID (e.g. Google, Facebook, etc.):
158+
159+ .. code-block :: php
160+
161+ try {
162+ $googleUser = $auth->getUserByProviderUid('google.com', 'google-uid');
163+ $facebookUser = $auth->getUserByProviderUid('facebook.com', 'facebook-uid');
164+ } catch (\Kreait\Firebase\Exception\Auth\UserNotFound $e) {
165+ echo $e->getMessage();
166+ }
167+
168+ .. note ::
169+ Since this method couldn't be added to the ``Kreait\Firebase\Contract\Auth `` interface without causing a breaking
170+ change, a new transitional interface/contract named ``Kreait\Firebase\Contract\Transitional\FederatedUserFetcher ``
171+ was added. This interface will be removed in the next major version of the SDK.
172+
173+ There are several ways to check if you can use the ``getUserByProviderUid() `` method:
174+
175+ .. code-block :: php
176+
177+ use Kreait\Firebase\Contract\Transitional\FederatedUserFetcher;
178+ use Kreait\Firebase\Factory;
179+
180+ $auth = (new Factory())->createAuth();
181+
182+ if (method_exists($auth, 'getUserByProviderUid')) {
183+ $user = $auth->getUserByProviderUid('google.com', 'google-uid');
184+ }
185+
186+ if ($auth instanceof \Kreait\Firebase\Auth) { // This is the implementation, not the interface
187+ $user = $auth->getUserByProviderUid('google.com', 'google-uid');
188+ }
189+
190+ if ($auth instanceof FederatedUserFetcher) {
191+ $user = $auth->getUserByProviderUid('google.com', 'google-uid');
192+ }
193+
151194************************************
152195Get information about multiple users
153196************************************
0 commit comments