fix: OAuth Redirect UTI가 사전 값과 다른 경우 domain 보정

This commit is contained in:
2022-08-28 18:00:53 +09:00
parent 517c85d003
commit 8cb2e2a447
2 changed files with 17 additions and 8 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ if(!$auth_code){
//TODO: /oauth/token //TODO: /oauth/token
$restAPI = new Kakao_REST_API_Helper(); $restAPI = new Kakao_REST_API_Helper('');
$result = $restAPI->create_access_token($auth_code); $result = $restAPI->create_access_token($auth_code);
//항상 scope = account_email profile임 //항상 scope = account_email profile임
+16 -7
View File
@@ -72,12 +72,27 @@ class Kakao_REST_API_Helper
private $access_token; private $access_token;
private $admin_key; private $admin_key;
public function __construct($access_token = '') private string $REST_KEY; // 디벨로퍼스의 앱 설정에서 확인할 수 있습니다.
private string $REDIRECT_URI; // 설정에 등록한 사이트 도메인 + redirect uri
private $AUTHORIZATION_CODE = ''; // 동의를 한 후 발급되는 code
private $REFRESH_TOKEN = '';
public function __construct($access_token = '', bool $changeRedirectDomain = true)
{ {
if ($access_token) { if ($access_token) {
$this->access_token = $access_token; $this->access_token = $access_token;
} }
if($changeRedirectDomain && key_exists('HTTP_HOST', $_SERVER)){
$uriObj = \phpUri::parse(KakaoKey::REDIRECT_URI);
$uriObj->authority = $_SERVER['HTTP_HOST'];
$this->REDIRECT_URI = $uriObj->join('');
}
else{
$this->REDIRECT_URI = KakaoKey::REDIRECT_URI;
}
$this->REST_KEY = KakaoKey::REST_KEY;
self::$admin_apis = array( self::$admin_apis = array(
User_Management_Path::$USER_IDS, User_Management_Path::$USER_IDS,
Push_Notification_Path::$REGISTER, Push_Notification_Path::$REGISTER,
@@ -268,10 +283,4 @@ class Kakao_REST_API_Helper
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
// API Test // API Test
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
private $REST_KEY = KakaoKey::REST_KEY; // 디벨로퍼스의 앱 설정에서 확인할 수 있습니다.
private $REDIRECT_URI = KakaoKey::REDIRECT_URI; // 설정에 등록한 사이트 도메인 + redirect uri
private $AUTHORIZATION_CODE = ''; // 동의를 한 후 발급되는 code
private $REFRESH_TOKEN = '';
} }