0
我是使用OAuth2.0的新手。現在,我正在使用cURL請求access_token,並且如預期那樣工作得很好。但我現在關心的是,這是安全的嗎?因爲,client_id和client_secret可以暴露?或者會有一種安全的方式來連接/向OAuth服務器請求access_token?非常感謝。使用cURL安全性的OAuth2.0請求access_token
$post = [
'grant_type' => 'client_credentials',
];
$ch = curl_init('http://laravelxampp.dev/oauth/access_token');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Basic ZjNkMjU5ZGRkM2VkOGZmMzg0MzgzOWI6NGM3ZjZmOGZhOTNkNTljNDU1MDJjMGFlOGM0YTk1Yg==',
'Accept: application/json',
'Accept-Language: en_US'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
$secret = json_decode($response);
return $secret->access_token;