Closed JulioCCosta closed 5 years ago
create from your Api route
Route::post('api/sociallogin/{provider}', 'YourAuthController@SocialSignup');
Route::post('api/auth/{provider}', 'YourOutController@index')->where('vue', '.*');
Route::post(api/'auth/{provider}/callback', 'YourOutController@index')->where('vue', '.*');
than
YourAuthController
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Socialite;
class AuthController extends Controller
{
public function __construct()
{
}
public function SocialSignup($provider)
{
// Socialite will pick response data automatic
$user = Socialite::driver($provider)->stateless()->user();
return response()->json($user);
}
}
@diadal I'm doing this, the problem is that in my client (vuejs) when I try to callback the package it only returns the code and not the token
` Vue.use(VueSocialauth, { baseUrl: API_URI, // Your API domain
providers: { github: { url: "http://localhost:8000/", clientId: '5c1fc8a9f5b57128f3b4', redirectUri:window.location.origin + "/login"
}
} })`
this return response()->json($user);
and dd($user)
are different
make sure your callback route point back to your index page Route::post(api/'auth/{provider}/callback', 'YourOutController@index')->where('vue', '.*')
then
Vue Router
{
path: 'api/auth/:provide/callback',
component: {
template: '<div class="auth-component"></div>'
}
},
I have two projects (api = laravel and client = vuejs) my real problem is that in the callback it redirects me to my api, how do I return to my client?