I am trying to use PHP curl to authenticate my app's user, but instead of authenticating with OAuth it returns the actual html login form as a response. Why? I don't want to redirect the user over and over every time the need to re-authenticate.
$params = "/authorize?response_type=code=&client_id=" . $clientAuth . "&client_secret=" . $clientSec . "&redirect_uri=" . $callBack; $auth_url = $instance_url; $headers = [ 'Content-type: application/x-www-form-urlencoded', ]; $ch = curl_init(); curl_setopt( $ch, CURLOPT_AUTOREFERER, true ); curl_setopt( $ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY ); curl_setopt( $ch, CURLOPT_USERAGENT, $agent ); curl_setopt( $ch, CURLOPT_URL, $auth_url ); curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch, CURLOPT_POST, count( $params ) ); curl_setopt( $ch, CURLOPT_POSTFIELDS, urlencode( $params ) ); $json_response = curl_exec( $ch ); $status = curl_getinfo( $ch, CURLINFO_HTTP_CODE ); echo '<pre>'; print_r( $json_response ); print_r( $status );
I am not sure why it only returns the form instead of performing the process as like it does if I use the browser to send the user there.
What am I doing to cause this issue?