From 456aa982b770fd18ca815f828686a829bb791de6 Mon Sep 17 00:00:00 2001 From: Jan Zikmund Date: Thu, 13 Jul 2023 15:17:30 +0200 Subject: [PATCH] allow redirect_uri param also for initial authentication --- src/Azure.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Azure.php b/src/Azure.php index 5d2eec6..4c6cbc1 100644 --- a/src/Azure.php +++ b/src/Azure.php @@ -147,14 +147,20 @@ public function azurecallback(Request $request) $code = $request->input('code'); try { + $form_params = [ + 'grant_type' => 'authorization_code', + 'client_id' => config('azure.client.id'), + 'client_secret' => config('azure.client.secret'), + 'code' => $code, + 'resource' => config('azure.resource'), + ]; + + if (Route::has('azure.callback')) { + $form_params['redirect_uri'] = route('azure.callback'); + } + $response = $client->request('POST', $this->baseUrl . config('azure.tenant_id') . $this->route . "token", [ - 'form_params' => [ - 'grant_type' => 'authorization_code', - 'client_id' => config('azure.client.id'), - 'client_secret' => config('azure.client.secret'), - 'code' => $code, - 'resource' => config('azure.resource'), - ] + 'form_params' => $form_params, ]); $contents = json_decode($response->getBody()->getContents());