In laravel docs there is a part about getting user from using ->userFromTokenAndSecret
however it seems to be not working with facebook and returns an error that this method doesn’t exist.
How do I get the user by token and secret?
I’m using Laravel as API so that it works stateless and I don’t use any redirects.
I sign in using Angular app and send token then. I need to process that.
3
Answers
I've found an answer to my questions and it is
userFromToken
. What is the idea:1) I authorize my user on Angular 6 using
ngx-social-login
2) I receive user data from Facebook
3) I send
authToken
to the API4) I receive user data from Facebook on my backend API using
Socialite::driver('facebook')->stateless()->userFromToken($token)
5) Do any stuff what I want. In my case I save data to DB or retrieve user if exists and then create a token for that user using JWT and return it
I also got problem but not facebook. I use twitter api with this plugin.
https://github.com/thujohn/twitter
I use socialite after get token from twitter plugin.
This is full that i was try to get token.
maybe it can help you.
the point code is here
so with $user i can get the email and another property there.
I had a work around to avoid method doesn’t exist "error"
$user = call_user_func(array(Socialite::driver("facebook"),"userFromToken"),$token);