kirbyallison
New member
i am integrating xenforo with laravel but i am facing issue regarding {"error":[{"code":"unauthorized","message":"api_error.unauthorized","params":[]}]} but i set all api_key premission Apikey section please i am new to this
Route::get('/auth/xenforo', function () {
$queryParams = http_build_query([
'client_id' => config('services.xenforo.client_id'),
'redirect_uri' => config('services.xenforo.redirect'),
'response_type' => 'code',
'state' => csrf_token(),
]);
$response = Http::withHeaders([
'Authorization' => 'Bearer ' . config('services.xenforo.api_key'),
'Accept' => 'application/json',
])->get(config('services.xenforo.base_url') . "/oauth/authorize?$queryParams");
Log::info('XenForo Callback Hit', ['response' => $response->json()]);
if ($response->successful()) {
return redirect($response->json('redirect_url'));
}
return response()->json([
'error' => $response->json('errors') ?? 'Failed to authenticate',
], $response->status());
});
Route::get('/auth/xenforo', function () {
$queryParams = http_build_query([
'client_id' => config('services.xenforo.client_id'),
'redirect_uri' => config('services.xenforo.redirect'),
'response_type' => 'code',
'state' => csrf_token(),
]);
$response = Http::withHeaders([
'Authorization' => 'Bearer ' . config('services.xenforo.api_key'),
'Accept' => 'application/json',
])->get(config('services.xenforo.base_url') . "/oauth/authorize?$queryParams");
Log::info('XenForo Callback Hit', ['response' => $response->json()]);
if ($response->successful()) {
return redirect($response->json('redirect_url'));
}
return response()->json([
'error' => $response->json('errors') ?? 'Failed to authenticate',
], $response->status());
});