I made a request to a github endpoint and got this error: I dont really know why
{"message":"Bad credentials","documentation_url":"https:\/\/docs.github.com\/rest"}
Heres the code:
$accesstoken = Session::get('gitaccesstoken');
$url = "https://api.github.com/user";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$headers = [
'Accept: application/vnd.github.v3+json, application/json',
'User-Agent: http://127.0.0.1:8000/'
];
if(Session::get('gitaccesstoken'))
$headers[] = 'Authorization: Bearer '.$accesstoken;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
return json_decode($response, true);