Twitter login with Laravel


#1

I am using Artdarek’s lib for Laravel but I have a problem.

when users try to login with Twitter they are redirected to Twitter authenticate page and asked for permission. But if they authorize that app Twitter redirects them to page

"Redirecting you back to the application. This may take a few moments."
and then redirect back to authenticate page on Twitter. authenticate?oauth_token=UNbRevLchuLCYxsDlgqHODQMmA4osBHoOKbzPLdkCs

Here is my config app/config/packages/artdarek/oauth-4-laravel/config.php

'storage' => 'Session', 
'consumers' => array(
    'Twitter' => array(
        'client_id'         => 'xxxxxxAPI key',
        'client_secret'     => 'xxxxxxAPI secret'
    )       
)

and here is my login function

public function twiiter() {
    $code = Input::get('code');
    $oauth_verifier = Input::get( 'oauth_verifier' );
    $twitterService = OAuth::consumer('Twitter');
    if(!empty($code)) {
        $token = $twitterService->getStorage()->retrieveAccessToken('Twitter');
        $twitterService->requestAccessToken( $code, $oauth_verifier, $token->getRequestTokenSecret() );
        $result = json_decode( $twitterService->request( 'account/verify_credentials.json') );
        $user = User::where( [ 'twitter_id' => $result->id ] )->first();
        if ( $user ) {
            $user->twitter_id = $result->id;
            $user->save();
            Auth::login($user);
            return Redirect::to('/');
        } else {

        }
    } else {
        $token = $twitterService->requestRequestToken();
        $url = $twitterService->getAuthorizationUri(['oauth_token' => $token->getRequestToken()]);
        return Redirect::to((string)$url);
    }
}

How to fix this problem? I checked in apps.twitter and my app can Sign in with Twitter, where did I made mistake?


#2

I have the same problem with you, you’ve resolved?