user3976041
user3976041

Reputation:

Laravel 5.3 passport ask http authentication

In my client i'm using following route to get auth token.

    Route::get('/redirect', function () {
    $query = http_build_query([
        'client_id' => '1',
        'redirect_uri' => 'http://localhost:8001/callback',
        'response_type' => 'code',
        'scope' => ''
    ]);

    return redirect('http://localhost:8000/oauth/authorize?'.$query);
});


Route::get('/callback', function (Illuminate\Http\Request $request) {
    $http = new \GuzzleHttp\Client;

    $response = $http->post('http://localhost:8000/oauth/token', [
        'form_params' => [
            'client_id' => '1',
            'client_secret' => 'secret-code',
            'grant_type' => 'authorization_code',
            'redirect_uri' => 'http://localhost:8001/callback',
            'code' => $request->code,
        ],
    ]);
    return json_decode((string) $response->getBody(), true);
});

but when i browse http://localhost:8001/redirect then it ask http authentication. Why authentication needed and how to resolve it?

enter image description here

Upvotes: 1

Views: 296

Answers (1)

Reno
Reno

Reputation: 11

Had the same problem today, and spent lots of time figuring out.

I finally found the cause: it seems that WWW-Authenticate headers are returned by Passport when you provide an invalid client (wrong clientID or wrong secret key).

And in fact, there was an error in my credentials, I fixed them and the problem was solved.

Hope this helps :)

Upvotes: 1

Related Questions