-
-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a way to create a User with Google Signin? #20
Comments
In theory it should work like this: $result = $auth->linkProviderThroughAccessToken('twitter', $twitterAccessTokenString)`;
$userRecord = $result->userRecord;
$result = $auth->linkProviderThroughAccessToken('google', $googleAccessTokenString)`;
$userRecord = $result->userRecord; When sent to the Firebase API, the access token will be parsed by them - if a matching user already exists (I don't know for sure how users would be matched), the credentials will be linked to the existing user. If no matching user exists, a new one will be created. Either way, you should receive a user record and consider the user signed in. The method is poorly named and undocumented because I added it in a weak moment when someone needed it, but I'm not able to reliably test it, and it's a functionality that would better be implemented in the frontend of an application. The flow that I would suggest in a web application would be to let the user sign in to Firebase in the browser (e.g. with https://firebase.google.com/docs/auth/web/firebaseui). There, you can get an ID token for the currently signed-in user as described in https://firebase.google.com/docs/auth/admin/verify-id-tokens#retrieve_id_tokens_on_clients This ID token can then be sent to your Laravel App and be verified by the SDK with $auth = app('firebase.auth');
$token = $auth->verifyIdToken($receivedIdTokenString);
$userRecord = $auth->getUser($token->getClaim('sub')); |
Great, thanks so much. |
Hello,
I have an existing Laravel API that currently uses standard JWT to authenticate users. I'm trying to add Google and Twitter SignIn functionality using this Firebase library, and I'm having trouble understanding the methods which I would use to create a user using third party signin. I am looking at the linkProviderThroughAccessToken in the Auth.php file, but I am still not understanding how I would initially create a user using the third party providers. Any help would be greatly appreciated!
The text was updated successfully, but these errors were encountered: