Reputation: 580
This is my first time working with Socialite and I can't seem to get it to work correctly.
Essentially, all I want is to return some account details of the currently authenticated account. I have it working when it comes to logging in and creating an account but when I try to return details using that account I'm greeted with the missing OAuth verifier error.
Here is a short video clip of my authorizing the app as expected and then clicking a link that should return JSON data about the account: https://youtu.be/LE8x9P8N_dU
Inside the controller for returning the account details I have:
public function getAccountInfo(){
$socialAccount = Socialite::with('twitter')->user();
return $socialAccount;
}
I was under the impression this would let me do things such as
$socialAccount->getAvatar();
ect however it doesn't appear to work.
I was following this tutorial for setting up Socialite: https://blog.damirmiladinov.com/laravel/laravel-5.2-socialite-twitter-login.html so my set up is almost exactly the same as this.
"laravel/framework": "5.4.*",
"laravel/socialite": "^3.0",
Any advice is greatly appreciated, I can provide any additional information you need please don't hesitate to ask for it.
Upvotes: 2
Views: 3141
Reputation: 9
You can check...
$request->exists('denied')
for Twitter and $request->exists('error')
for Linkedin. It working on my application in Laravel 6.0* with Socialite 4.0*.
if ($request->exists('denied') || $request->exists('error'))
{
// do something
}else{
$socialAccount = Socialite::driver($provider)->user();
}
Upvotes: 0
Reputation: 13259
Check this syntax
$socialAccount = Socialite::driver('twitter')->user();
If you want the account details of the currently authenticated user, use the same old
$user = Auth::user();
Upvotes: 1