callApiService = $callApiService; $this->appleTokenService = $appleTokenService; } public function redirectToProvider($provider) { $this->oauth2Info = request('oauth2Info'); // [$this->target, $ssoBrand] = explode('-', $provider); $brandCode = 'member-'.$provider; $response = $this->callApiService->callApi([ 'url' => 'setup-page', 'data' => [ 'PageVars' => [ 'Query' => "(setup_code = 'sso-client' and brand_code = '{$brandCode}') and is_on_use = '1'", 'Limit' => 100 ] ], ]); // dd($this->oauth2Info); // dd($response); if (!empty($response['Page'])) { $setupJson = $response['Page'][0]['SetupJson']; // dd($setupJson); $setupArray = json_decode($setupJson, true); $redirectUri = route('social.login', ['provider' => $brandCode]); if (json_last_error() === JSON_ERROR_NONE) { $clientId = $setupArray['ClientId'] ?? null; // dd($clientId); } } if ($provider == 'naver') { $url = 'https://nid.naver.com/oauth2.0/authorize?' . http_build_query([ 'response_type' => 'code', 'client_id' => $clientId, 'redirect_uri' => $redirectUri, 'state' => csrf_token(), ]); } elseif ($provider == 'kakao') { $url = 'https://kauth.kakao.com/oauth/authorize?' . http_build_query([ 'response_type' => 'code', 'client_id' => $clientId, 'redirect_uri' => $redirectUri, 'state' => csrf_token(), ]); } // dd($url); return redirect($url); } public function login($provider) { // dd($provider); [$this->target, $ssoBrand] = explode('-', $provider); if ($this->target == 'member') { if ($ssoBrand == 'naver') { // return Redirect::away('https://talk.naver.com/ct/w5u3g9'); echo ""; return; }elseif($ssoBrand == 'kakao'){ echo ""; return; // return Redirect::away('https://pf.kakao.com/_aAAGj/chat'); } } } public function setConfig($provider, $target) { $config = [ 'client_id' => $this->oauth2Info['ClientId'], 'client_secret' => $this->oauth2Info['ClientSecret'], 'redirect' => "/social/$target-$provider/callback" ]; switch ($provider) { case 'dabory': $driver = Socialite::buildProvider(DaboryProvider::class, [ 'client_id' => config('app.api.main.ClientId'), 'client_secret' => config('app.api.main.ClientSecret'), 'redirect' => $config['redirect'] ]); break; case 'facebook': $driver = Socialite::buildProvider(FacebookProvider::class, $config); break; case 'kakao': $driver = Socialite::buildProvider(KakaoProvider::class, $config); break; case 'google': $driver = Socialite::buildProvider(GoogleProvider::class, $config); break; case 'naver': $driver = Socialite::buildProvider(NaverProvider::class, $config); break; case 'apple': $config['client_secret'] = $this->appleTokenService->generate( $this->oauth2Info['PrivateKey'], $this->oauth2Info['ClientId'], $this->oauth2Info['TeamId'], $this->oauth2Info['KeyId'], ); $driver = Socialite::buildProvider(Provider::class, $config); break; } return $driver; } }