Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

WinstonSmith's avatar

Is possible to get Access token for Session auth user?

I want tu authenticate login user by a web gruard with session driver and api with laravel password driver in this same time. For session auth I use a default laravel authentication, for api I want to use Laravel Password. I don’t, want modify basic laravel session auth controller , but write a different one. So I implement this:

Route::get('/auth', function () {
    $http = new \GuzzleHttp\Client;

        $response = $http->post(url('/oauth/token'), [
            'form_params' => [
                'grant_type' => 'password',
                'client_id' => '2',
                'client_secret' => 'TyRg3Jmcu95yhKHztDQHjzcvLMLdHzjqEW8AAYwt',
                'username' => Auth::user()->email,
                'password' => decrypt(Auth::user()->password), // Problem is with this
            ],
        ]);

    return (string)$response->getBody();
});

For get auth user access token but, I have problem with credentials. I can’t attempt auth user credentials with username, and user password from session auth user because his password is encryption. So my question is, how to get user access token with this situation for session auth user?

Thanks for your help or suggestion :)

0 likes
0 replies

Please or to participate in this conversation.