카카오 로그인 api 사용

안녕하세요
php 8.2버전, 라라벨 10버전에서
카카오 로그인 API를 사용하려고 합니다.
https://github.com/SocialiteProviders/Kakao
https://socialiteproviders.com/Kakao/#installation-basic-usage
를 참고하여 모든 설정이 끝난 이후
Route::get(‘/auth/callback’, function (Request $request) {
dd($request->all());
$kakaoUser = Socialite::driver(‘kakao’)->user();
dd($kakaoUser);
});

Route에서 값을 받았습니다>
dd($request->all());에서 code값을 받은 것을 확인했는데
아래 $kakaoUser = Socialite::driver(‘kakao’)->user();에서
localhost:8000/auth/callback 페이지 콘솔에서
Failed to load resource: the server responded with a status of 500 (Internal Server Error) 에러를 확인했습니다.

혹시 카카오 로그인 API를 사용할때 http는 카카오 로그인 api제공이 되지 않는 것인지 알고 싶습니다.

Hello @dbsrbtjs

I’ll help explain the Kakao Login API issue in

The error you’re encountering with Kakao Login API integration in Laravel 10 and PHP 8.2 could be due to several factors:

  1. HTTPS Requirement:
  • Kakao API generally requires HTTPS for security purposes
  • However, you can use HTTP (localhost) for development/testing
  • Make sure your Kakao Developer Console settings have the correct redirect URI:
    • For local testing: http://localhost:8000/auth/callback
    • Include both HTTP and HTTPS versions if needed
  1. To debug the 500 error, try this modified code:
    php
    Route::get(‘/auth/callback’, function (Request $request) {
    try {
    $kakaoUser = Socialite::driver(‘kakao’)->user();
    dd($kakaoUser);
    } catch (\Exception $e) {
    dd($e->getMessage()); // This will show the actual error
    }
    });

  2. Common solutions:
    Verify your .env configuration:

KAKAO_CLIENT_ID=your_client_id
KAKAO_CLIENT_SECRET=your_client_secret
KAKAO_REDIRECT_URI=http://localhost:8000/auth/callback

Check your config/services.php:
php
‘kakao’ => [
‘client_id’ => env(‘KAKAO_CLIENT_ID’),
‘client_secret’ => env(‘KAKAO_CLIENT_SECRET’),
‘redirect’ => env(‘KAKAO_REDIRECT_URI’),
],

Make sure the redirect URI in Kakao Developer Console matches exactly with your configuration
Clear Laravel’s configuration cache:
bash
php artisan config:clear
php artisan cache:clear

If you’re still getting the 500 error, you can check your Laravel logs (storage/logs/laravel.log) for more detailed error information. The issue is likely not related to using HTTP on localhost, as Kakao does allow HTTP for development purposes.

For production environments, you should always use HTTPS as it’s required for security reasons.

If your issue is not resolved, please provide more details and we will try to find a solution.

1개의 좋아요

@dbsrbtjs
안녕하세요.

http도 사용 가능합니다.
500 (Internal Server Error) 는 개발하신 시스템에서 발생하는 에러 입니다.

어떤 에러인지 로깅 해보시면 좋을 것 같습니다.
더 자세한 확인 원하시면 에러 로그와 디벨로퍼스앱 ID 기재해주세요.

1개의 좋아요