Laravel Socialite: Invalid request. Missing OAuth verifier. (Twitter)

百般思念 提交于 2019-12-02 04:58:05

问题


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.


回答1:


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();



回答2:


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();
}


来源:https://stackoverflow.com/questions/42193340/laravel-socialite-invalid-request-missing-oauth-verifier-twitter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!