Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 2

GitHub OAuth error

Hi,

 

I'm getting this error: 'object(stdClass)#1 (1) { ["error"]=> string(9) "Not Found" } '.

 

I'm making "Log in with GitHub" system with PHP and that's what I got.

Code:

<?php 
	
	$code = $_GET['code'];
	

	if($code == "")
	{
		header('Location: http://localhost:80/user/');
	}

	$CLIENT_ID = "private";
	$CLIENT_SECRET = "private";
	$URL = "https://github.com/login/oauth/access_token";

	$postParams =
	[
		'client_id' == $CLIENT_ID,
		'client_secret' == $CLIENT_SECRET,
		'code' == $code
	];
	$ch = curl_init();

	curl_setopt($ch, CURLOPT_URL, $URL);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $postParams);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
	$response = curl_exec ($ch);
	
	curl_close($ch);


	$data = json_decode($response);
	
	echo '<br/>';

	var_dump($data);
 ?>

Thanks in advance.

1 Reply
Highlighted
Community Manager
Message 2 of 2

Re: GitHub OAuth error

Unfortunately, we won't be able to help you debug your PHP script. But if you can supply a minimal repro case using a tool like curl or HTTPie, giving us the command you used (with any security tokens redacted, of course) and the response you received, we can help debug from there.

 

Let us know!