I am using the bitbucket api and there I am getting an access token when I enter the following url: 'https://bitbucket.org/site/oauth2/authorize?client_id={client_id}&response_type=code' and it redirects me to https://api.bitbucket.org/2.0/repositories/{my-team}/?code={code} And I need to get that {code} from the redirect url I do it with curl the following way:
public function getCode()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://bitbucket.org/site/oauth2/authorize?client_id=".config('app.bitbucket_key')."&response_type=code");
$result = curl_exec($ch);
if (curl_errno($ch)) {
return 'Error: invalid credentials';
}
return $result;
}
but as a result I get true. I want to get the code query parameter in the redirect url. How can I do this
EDIT:
When I check with curl_getinfo()
I see that it redirects me to another url which is: https://bitbucket.org/account/signin/?next=/site/oauth2/authorize%3Fclient_id%3D{my_client_id}%26response_type%3Dcode