Created
September 21, 2015 15:02
-
-
Save barooney/8f7eccfef626a0aeadbe to your computer and use it in GitHub Desktop.
Laravel Socialite and Hello.js implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Schoolm8\Http\Requests; | |
use Illuminate\Support\Facades\Session; | |
use Schoolm8\Http\Controllers\Controller; | |
use Laravel\Socialite\Facades\Socialite; | |
class AuthController extends Controller { | |
public function proxy( Request $request ) { | |
if ( ! $request->oauth_token ) { | |
$state = json_decode( $request->state ); | |
$redirect_uri = $request->redirect_uri; | |
Session::put('state', $request->state); | |
Session::put('redirect_uri', $redirect_uri); | |
return Socialite::driver( $state->network )->redirect(); | |
} else { | |
$state = json_decode( Session::get('state') ); | |
$redirect_uri = Session::get('redirect_uri'); | |
$user = Socialite::driver( $state->network )->user(); | |
return redirect( | |
$redirect_uri . '#' . | |
'user_id=' . $user->getId() . '&' . | |
'screen_name=' . $user->getName() . '&' . | |
'x_auth_expires=0&' . | |
'access_token=' . $user->token . '&' . | |
'state=' . json_encode($state, JSON_UNESCAPED_SLASHES) | |
); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello.on('auth.login', function(auth) { | |
// put your callbacks here | |
console.log(auth); | |
}); | |
hello.init({ | |
facebook: facebookClientId, | |
twitter: twitterClientId | |
}, { | |
display: 'popup', | |
oauth_proxy: 'http://server/path/to/proxy-route' | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment